The regular expression matches the email address [\ w] + @ [\ w] +. [\ w] {2, 3} \ w to match any word characters including underlines. It is equivalent to \ '[A-Za-z0-9 _] \'. + Match the previous subexpression once or multiple times.
For example, 'Zo + 'can match "zo" and "zoo", but cannot match "z ". + Is equivalent to {1 ,}. Both {n, m} m and n are non-negative integers, where n <= m. Match at least n times and at most m times. For example, "o {1, 3}" matches the first three o in "fooooood. 'O {0, 1} 'is equivalent to 'o? '. Note that there must be no space between a comma and two numbers.
Example of a regular expression for Javascript mailbox Verification
The Code is as follows: |
Copy code |
Myreg =/^ ([a-zA-Z0-9] + [_ |.]?) * [A-zA-Z0-9] + @ ([a-zA-Z0-9] + [_ |.]?) * [A-zA-Z0-9] +. [a-zA-Z] {2, 4} $/; Javascript
|
Email address verification Regular Expression example
The Code is as follows: |
Copy code |
<Script type = "text/javascript"> Function isEmail (val ){ Var myreg =/^ ([a-zA-Z0-9] + [_ |.]?) * [A-zA-Z0-9] + @ ([a-zA-Z0-9] + [_ |.]?) * [A-zA-Z0-9] +. [a-zA-Z] {2, 4} $ /; If (! Myreg. test (val )) Return 'not mailbox '; Return 'yesmail '; }; Alert (isEmail ('I @ fufuok.com ')); </Script>
|
Ii. Explanations
1./^ $/This is a common format.
^ Match the start position of the input string; $ match the end position of the input string
2. Enter the functions to be implemented.
* Matches the previous subexpression zero or multiple times;
+ Match the previous subexpression once or multiple times;
? Match the previous subexpression zero or one time;
D matches a digit, which is equivalent to [0-9].