一、手机号码
1 public static boolean mobileMumVerify(String phoneNum) 2 { 3 Pattern p = Pattern 4 .compile("^((13[0-9])|(15[^4,\\D])|(170)|(18[0,5-9])|(14[5,7]))\\d{8}$"); 5 return p.matcher(phoneNum).matches(); 6 }
二、邮箱
1 public static boolean mailAddressVerify(String mailAddress) 2 { 3 String emailExp = "^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3} )(\\]?)$"; 4 Pattern p = Pattern.compile(emailExp); 5 return p.matcher(mailAddress).matches(); 6 }
时间: 2024-10-27 10:09:13