java后台正则验证
1 public static boolean checkPhone(String phone) 2 { 3 Pattern pattern = Pattern.compile("^[1][3-8]+\\d{9}$"); 4 Matcher matcher = pattern.matcher(phone); 5 if (matcher.matches()) 6 { 7 return true; 8 } 9 return false; 10 } 11 12 public static boolean checkEmail(String email) 13 { 14 Pattern pattern = Pattern.compile("^/w+([-.]/w+)*@/w+([-]/w+)*/.(/w+([-]/w+)*/.)*[a-z]{2,3}$"); 15 Matcher matcher = pattern.matcher(email); 16 if (matcher.matches()) 17 { 18 return true; 19 } 20 return false; 21 }