开发者社区 问答 正文

如何用正则表达式判断邮箱地址是否合法?

如何用正则表达式判断邮箱地址是否合法?

展开
收起
爵霸 2016-06-13 13:33:17 2782 分享 版权
1 条回答
写回答
取消 提交回答
  • package src;
     
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;
     
     
    public class testemail {
     
        public static void main(String args[]){
     
            Pattern p=Pattern.compile("[\\w!#$%&'*+/=?^_`{|}~-]+(?:\\.[\\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\\w](?:[\\w-]*[\\w])?\\.)+[\\w](?:[\\w-]*[\\w])?");
            Matcher m=p.matcher("test@qq.com");
            while(m.find()){
                System.out.println(m.group());
            }
        }
    }
    2019-07-17 19:35:43
    赞同 展开评论
问答标签:
问答地址: