Android正则匹配实例
来源:互联网 发布:人工智能的上市公司 编辑:程序博客网 时间:2024/05/18 14:45
匹配车辆牌照的前位,如”浙B”
/** * 检查车牌前两位 * @param licensePlate * @return true:符合;false:不符合 */public static boolean checkCarLicensePlate(String licensePlate) { if (!TextUtils.isEmpty(licensePlate)) { Pattern p = Pattern.compile("(京|沪|津|渝|黑|吉|辽|蒙|冀|新|甘|青|陕|宁|豫|鲁|晋|皖|鄂|湘|苏|川|黔|滇|桂|藏|浙|赣|粤|闽|台|琼|港|澳){1}[A-Z]{1}"); Matcher m = p.matcher(licensePlate); if (m.matches()) { return true; }else { return false; } } return false;}
匹配特殊的字符串
/** * 过滤特殊字符 * @param str * @return */public static String replaceBlank(String str) { String dest = ""; if (str!=null) { Pattern p = Pattern.compile("\\s*|\t|\r|\n"); Matcher m = p.matcher(str); dest = m.replaceAll(""); } return dest;}
阅读全文
0 0
- Android正则匹配实例
- 正则匹配实例
- 高效正则表达式匹配实例:
- 常用的匹配正则表达式和实例
- 常用的匹配正则表达式和实例
- 常用的匹配正则表达式和实例
- 常用的匹配正则表达式和实例
- 常用的匹配正则表达式和实例
- 常用的匹配正则表达式和实例
- 常用的匹配正则表达式和实例
- 常用的匹配正则表达式和实例
- 常用的匹配正则表达式和实例
- 常用的匹配正则表达式和实例
- 常用的匹配正则表达式和实例
- 常用的匹配正则表达式和实例
- 常用的匹配正则表达式和实例
- 常用的匹配正则表达式和实例
- 常用的匹配正则表达式和实例
- ssm多数据源配置
- 利用Spring AOP实现业务和异常日志记录
- Drools整和Maven项目开发
- 三种东西永远不要放到数据库里
- 细粒度 锁 实现
- Android正则匹配实例
- ios解决bug--“Pushing the same view controller instance more than once is not supported”
- Dev TreeList添加自带节点搜索
- centos下git的安装及配置
- Python爬虫入门一之综述
- vi 命令大全
- instruments工具的使用
- jsp学习1
- 树莓派(Raspberry Pi 3)