The most authentic regular statement of mailbox regex is ^[a-z0-9] ([._\\-]*[a-z0-9])*@([a-z0-9] [-a -z0-9]*[a-z0-9] .){1,63}[a-z0-9] $ Let’s explain the regular rules of
fuchangxi:
/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/
It must start with one or more word characters or -, plus @, and then one or more word characters or -. Then there is a combination of dot "." and word characters and -. There can be one or more combinations.
I don’t know much about the specific rules of email. I feel that this regular rule is relatively simple
Count the types of email @ prefixes
1. Pure numbers
For example: 123456@jb51.net
2. Pure letters
3. Mixed letters and numbers
4. Dotted
For example: web.blue@jb51.net
5. Underlined
For example: web_blue@jb51.net
6. With connecting lines
For example: web-blue@jb51.net
The email domain must have at least one "." and two words. To be stricter, the final top-level domain must be at least 2 letters. What is the maximum? Based on the domain name "name", the maximum is 4. If it is more relaxed, let's set it to 5^_^.
Of course the above is impossible: starting or ending with "_" or "-" and containing special symbols.
Therefore, the regular expression I gave is as follows:
^[A-Za-zd]+([-_.][A-Za-zd]+)*@([A-Za-zd]+[-.])+[A-Za-zd]{2,5}$
邮箱不能以 - _ .以及其它特殊字符开头和结束
邮箱域名结尾为2~5个字母,比如cn、com、name
Related articles:
Regular expression for verifying email
Related videos:
JavaScript Regular Expression Video Tutorial
The above is the detailed content of Detailed explanation of regular expressions for verifying email using js (with code). For more information, please follow other related articles on the PHP Chinese website!