java 验证邮箱格式


 1 private static void yzyx(String str) {
 2         // TODO Auto-generated method stub
 3         
 4         String tegex="[a-zA-Z0-9_]+@\\w+(\\.com|\\.cn){1}";
 5         boolean flag=str.matches(tegex);
 6         if(flag){
 7             System.out.println("邮箱格式正确");
 8         }else{
 9             System.out.println("邮箱格式有误");
10         }
11     }

相关