首页 > 代码库 > java邮箱正则验证

java邮箱正则验证

 

 

import java.util.*;import java.util.regex.Matcher;import java.util.regex.Pattern;public class test{    public static void main(String args[]){        System.out.println(test.isEmail("lala@qq.com"));      }    public static boolean isEmail(String email){             String str="^" +                "([a-zA-Z0-9]*[-_]?[a-zA-Z0-9]+)*@" +                "([a-zA-Z0-9]*[-_]?[a-zA-Z0-9]+)+" +                "[\\.][A-Za-z]{2,3}" +                "([\\.][A-Za-z]{2})?" +                "$";        Pattern p = Pattern.compile(str);             Matcher m = p.matcher(email);             return m.matches();          } }