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     }

 

posted @ 2016-01-04 15:14  欧文_Owen  阅读(1416)  评论(0编辑  收藏  举报