标签:
private boolean isName(String name) {
String strPattern = "^[a-zA-Z][a-zA-Z0-9_]{4,15}$";
Pattern p = Pattern.compile(strPattern);
Matcher m = p.matcher(name);
return m.matches();
}
// 邮箱的验证
private boolean isEmail(String email) {
// String strPattern = "^[a-zA-Z][a-zA-Z0-9_]{4,15}$";
String strPattern = "^[a-zA-Z0-9][\\w\\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\\w\\.-]*[a-zA-Z0-9]\\.[a-zA-Z][a-zA-z\\.]*[a-zA-z]$";
Pattern p = Pattern.compile(strPattern);
Matcher m = p.matcher(email);
return m.matches();
}
// 手机号的验证
private boolean isMobile(String mobile) {
String strPattern = "^((13[0-9])|(15[^4,\\D])|(18[0,1,5-9]))\\d{8}$";
// String strPattern = "^1[3,5,8]\\d{9}$";
Pattern p = Pattern.compile(strPattern);
Matcher m = p.matcher(mobile);
return m.matches();
}
// 身份证的验证
private boolean isCard(String card) {
String strPattern = "^\\d{15}|\\d{18}$";
Pattern p = Pattern.compile(strPattern);
Matcher m = p.matcher(card);
return m.matches();
}
标签:
原文地址:http://www.cnblogs.com/BrightPoplar/p/4836578.html