Java regex email

后端 未结 20 2607
清歌不尽
清歌不尽 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:23

    Try the below code for email is format of

    jsmith@example.com
    

    1st part -jsmith 2nd part -@example.com

    1. In the 1 part it will allow 0-9,A-Z,dot sign(.),underscore sign(_)
     2. In the 2 part it will allow A-Z, must be @ and .
    
    ^[a-zA-Z0-9_.]+@[a-zA-Z.]+?\.[a-zA-Z]{2,3}$
    

提交回复
热议问题