那么现在就可以正则匹配测试了,
public static boolean isMobileNO(String mobiles){ Pattern p = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$"); Matcher m = p.matcher(mobiles); return m.matches(); }
第二种方法:
String value="手机号"; String regExp = "^[1]([3][0-9]{1}|59|58|88|89)[0-9]{8}$"; Pattern p = Pattern.compile(regExp); Matcher m = p.matcher(value); return m.find();//boolean
String str = "^[1-9][0-9]{5}$"; /** * 判断邮编 * @param paramString * @return */ public static boolean isZipNO(String zipString){ String str = "^[1-9][0-9]{5}$"; return Pattern.compile(str).matcher(zipString).matches(); }
/** * 判断邮箱是否合法 * @param email * @return */ public static boolean isEmail(String email){ if (null==email || "".equals(email)) return false; //Pattern p = Pattern.compile("\\w+@(\\w+.)+[a-z]{2,3}"); //简单匹配 Pattern p = Pattern.compile("\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");//复杂匹配 Matcher m = p.matcher(email); return m.matches(); }
android 判断 手机号码、邮编、Email邮箱、是否正确
原文:http://blog.csdn.net/gao_chun/article/details/39580363