Java regex email

后端 未结 20 2450
清歌不尽
清歌不尽 2020-11-22 13:09

First of all, I know that using regex for email is not recommended but I gotta test this out.

I have this regex:

\\b[A-Z0-9._%-]+@[A-Z0-9.-]+\\.[A-Z]         


        
20条回答
  •  野性不改
    2020-11-22 13:47

    That's because you are forgetting case insensitivity :

    Pattern regex = Pattern.compile("\\b[\\w.%-]+@[-.\\w]+\\.[A-Za-z]{2,4}\\b");
    

    This matches your example, although it ignores many valid e-mails.

提交回复
热议问题