In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail what Email regular expressions are, and the editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
When it comes to regular expressions, there are many general expressions on the Internet, but in fact, most people don't want to study them, just use them directly. However, in fact, there may be times when the actual situation in the project or in the company is different, so we have to modify the regular expression and customize it according to the actual situation, which requires us to seriously learn some writing methods of the regular expression, borrowlism, which not only allows us to enjoy the rich network sharing resources, but also brings us inertia. I will not introduce some of the use of regular expressions. There are many introductions on the Internet.
Some time ago, the editor had to correct the email in the project. Allow you to enter multiple email, separated by;, and then, when submitted in the page form, verify whether it is a single message or multiple messages. I won't say much about whether it is multiple messages or a single message. When there are multiple messages, you just need to use split (";") to generate an array, and then loop through each email to determine whether the correct email format is correct. This is not the point that the editor wants to talk about. I just want to explain what I want to correct here.
A general email, such as zhangshan@163.com,abc@sina.com.cn, is fine, but in some of our customers' mailboxes, there are some similar forms of zhangshna.Mr@163.com,abc_Wang.dd@sian.com,abc_Wang.dd.cc@sian.com, which were used before the @ symbol, but not now. We have to study the usage of the rules ourselves.
Friends, if you have any questions about regular expressions, you are welcome to leave messages here for exchange and discussion!
The original regular expression
/ ^ [a-zA-Z0-9 percent -] + @ [a-zA-Z0-9 percent -] + (\ .[ a-zA-Z0-9 percent -] +) + $/
My modified regular expression according to my actual situation
/ ^ (\ w) + (\.\ w +) * @ (\ w) + ((\.\ w {2jue 3}) {1jue 3}) $/
Or
/ ^ (\ w) + (\.\ w +) * @ (\ w) + ((\.\ w +)) $/
Character description:
^: match the starting position of the input.
\: Mark the next character as a special character or literal value.
*: matches the previous character zero or several times.
+: matches the previous character one or more times.
(pattern) match the pattern and remember to match.
X | y: matches x or y.
[amurz]: represents a range of characters. Matches any character in the specified range.
\ w: matches any word character, including an underscore.
{ncentine m} match at least n times and at most m times
$: matches the end of the input.
With a simple js
Function checkEmail () {var emailValue=document. GetElementById_r ("email"). Value; if (! isEmail (emailValue)) {alert ("the mailbox you entered is wrong, please check it again!"); document. GetElementById_r ("email"). Focus (); return false;} return true;} function isEmail (str) {var reg = / ^ (\ w) + (\.\ w +) * @ (\ w) + (\.\ w +) +) $/; return reg.test (str);}
The correction method for entering multiple emails is also attached.
/ / correct mailbox format should be correct 20080602_heyitang
Var email=document. GetElementById_r ("trans_email"). Value
/ / if the user enters the mailbox to make a judgment
If (emailworthy email null) {if (email.indexOf (";") =-1) {if (! isEmail (email)) {alert ("the format of the single email you entered is incorrect, please check it again before entering"); document. GetElementById_r ("trans_email"). Focus (); return false;}} else {var emailArray=email.split (";"); for
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.