标签:
1.验证是否是Email地址
public static boolean isEmail(String value) { String emailPattern = "^([a-zA-Z0-9]*[-_]?[a-zA-Z0-9]+)*@([a-zA-Z0-9]*[-_]?[a-zA-Z0-9]+)+[\\.][A-Za-z]{2,3}([\\.][A-Za-z]{2})?$"; Pattern p = Pattern.compile(emailPattern); Matcher m = p.matcher(value); return m.matches(); }
2.验证是否是手机号码
public static boolean isMobilePhone(String value) { String mobilePhonePattern = "^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$"; Pattern p = Pattern.compile(mobilePhonePattern); Matcher m = p.matcher(value); return m.matches(); }
标签:
原文地址:http://www.cnblogs.com/chenchaochao/p/5596083.html