Detailed explanation of regular expressions for verifying email using js (with code)

php是最好的语言
Release: 2018-08-06 17:51:54
Original
9603 people have browsed it

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_-])+/
Copy after login

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.

Copy after login

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}$
Copy after login
   

邮箱不能以 - _ .以及其它特殊字符开头和结束

邮箱域名结尾为2~5个字母,比如cn、com、name

Copy after login

Related articles:

Detailed explanation of the regular expression js code for authenticating email addresses_regular Expression

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!