安卓基础--常用的正则表达式
来源:互联网 发布:手机adb软件 编辑:程序博客网 时间:2024/06/05 18:37
public class RegExUtil {//判空public static boolean isNull(String msg){if(msg==null||"".equals(msg)||msg.length()==0||"null".endsWith(msg.toLowerCase())){return true;}else{return false;}}//电话号码判断public static boolean checkPhoneNum(String phoneNum){Pattern patternPhone = Pattern.compile("^((13[0-9])|(147)|(15[0-9])|(18[0-9]))\\d{8}$",Pattern.CASE_INSENSITIVE);Matcher matcherPhone = patternPhone.matcher(phoneNum);return matcherPhone.matches();}
//昵称判断(只能汉字、数字、字母)
public static boolean checkNick(String Nick){Pattern patternPhone = Pattern.compile("^[\u4e00-\u9fa5a-zA-Z0-9]+$",Pattern.CASE_INSENSITIVE);Matcher matcherPhone = patternPhone.matcher(Nick);return matcherPhone.matches();}
//身份证号判断
public static boolean checkIDNumber(String IDnum){Pattern patternPhone = Pattern.compile("(\\d{14}[0-9a-zA-Z])|(\\d{17}[0-9a-zA-Z])",Pattern.CASE_INSENSITIVE);Matcher matcherPhone = patternPhone.matcher(IDnum);return matcherPhone.matches();}
//姓名判断(只能输入汉字和字母)
public static boolean checkRealName(String realName){Pattern name = Pattern.compile("^([A-Za-z]|[\u4E00-\u9FA5])+$",Pattern.CASE_INSENSITIVE);Matcher matcherPhone = name.matcher(realName);return matcherPhone.matches();}
//密码不能为汉字
public static boolean checkChinese(String password){Pattern p=Pattern.compile("[\u4e00-\u9fa5]"); Matcher m = p.matcher(password); return m.matches();}
// 判断车牌号
public static boolean checkCarCode(String carcode){ String type = "[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1}$"; Pattern p=Pattern.compile(type); Matcher m=p.matcher(carcode); if(m.matches()){ return true; } return false;}
}
阅读全文
0 0
- 安卓基础--常用的正则表达式
- 基础常用的正则表达式
- 安卓项目中常用的正则表达式
- 安卓正则表达式
- 安卓正则表达式
- 安卓手机号码的正则表达式
- 安卓常用正则表达式(手机号,邮箱等等)
- PHP基础常用正则表达式
- 正则表达式常用字符基础
- 正则表达式---常用的正则
- 正则表达式---常用的正则
- 正则表达式 常用的正则
- 常用的正则表达式
- 常用的正则表达式
- 常用的正则表达式
- 常用的正则表达式
- 常用的正则表达式
- 常用的正则表达式
- ssh连接共享
- 给新的虚拟系统磁盘分区(从虚拟机创建到项目运行二)
- 向数组中插入元素排序
- React动画效果
- 文章标题
- 安卓基础--常用的正则表达式
- 可折叠手机要来了?三星正在计划中。。。
- RecyclerView 配合 DiffUtil,好用到飞起
- Disconf入门指南(1)
- Warning:Conflict with dependency 'com.google.code.findbugs:jsr305'
- Python列表,集合,字典
- 学习javaSE 类和对象,方法,构造方法,成员变量与局部变量
- 十分钟学会Charles抓包(iOS的http/https请求)
- 【Web前端学习笔记】Javascript_03_常用对象:String,Number,Math,Date,网页时针