In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces you to verify the mailbox regular expression js code how to write, the content is very detailed, interested friends can refer to, hope to be helpful to you.
The regularity of fuchangxi:
The code is as follows:
/ ^ ([a-zA-Z0-9 percent -]) + @ ([a-zA-Z0-9 percent -]) + (. [a-zA-Z0-9 percent -]) + /
First it has to be one or more word characters or -, plus @, and then one or more word characters or -. And then there's the dot. There can be one or more combinations of and word characters and -.
The code is as follows:
Function isEmail (str) {
Var reg = / ^ ([a-zA-Z0-9 percent -]) + @ ([a-zA-Z0-9 percent -]) + (. [a-zA-Z0-9 percent -]) + /
Return reg.test (str)
}
Var str = 'test@hotmail.com'
[xss_clean] (isEmail (str) +'')
Var str2 = 'test@sima.vip.com'
[xss_clean] (isEmail (str2) +'')
Var str3 = 'te-st@qq.com.cn'
[xss_clean] (isEmail (str3) +'')
Var str4 = 'te_st@sima.vip.com'
[xss_clean] (isEmail (str4) +'')
Var str5 = 'te.._st@sima.vip.com'
[xss_clean] (isEmail (str5) +'')
I don't know much about the specific rules of mailbox. I feel that this regularity is relatively simple.
Count several types of mailbox @ prefixes
1. Pure number
For example: 123456@jb51.net
2. Pure letters
3. Alphanumeric mixing
4. With dots
For example: web.blue@jb51.net
5. Underline
For example: web_blue@jb51.net
6. With connecting wire
For example: web-blue@jb51.net
The mailbox domain has at least one "." And two words, a little more strict, so the final top-level field needs at least 2 letters, the largest? If the domain name "name" prevails, then the maximum is 4, and the leniency point is set to 5 bar ^ _ ^.
Of course, in the above impossible cases: beginning or ending with "_" or "-" and containing special symbols.
Therefore, the regular expression I give is as follows:
^ [A-Za-zd] + ([- _.] [A-Za-zd] +) * @ ([A-Za-zd] + [-.]) + [A-Za-zd] {2jue 5} $
The copy code is as follows:
FChkMail=function (szMail) {
Var szReg=/ ^ [A-Za-zd] + ([- _.] [A-Za-zd] +) * @ ([A-Za-zd] + [-.]) + [A-Za-zd] {2jue 5} $/
Var bChk=szReg.test (szMail)
Return bChk
}
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.