For example, ' zo+ ' can match "Zo" and "Zoo", but cannot match "Z". + is equivalent to {1,}. {n,m} m and n are non-negative integers, where n <= m. Matches n times at least and matches up to M times. For example, "o{1,3}" will match the first three o in "Fooooood". ' o{0,1} ' is equivalent to ' o '. Notice that there is no space between the comma and the two number.
Javascript Mailbox Validation Regular Expression example
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
|
Example of a mailbox validation regular expression
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 ' is not a mailbox '; return ' is mailbox '; }; Alert (isemail (' i@fufuok.com ')); </script> |
Two. Explain the relevant meaning
1. /^$/This is a generic format.
^ matches the start position of the input string; $ matches the end position of the input string
2. Inside, enter the functionality you want to implement.
* matches the preceding subexpression 0 or more times;
+ Matches the preceding subexpression one or more times;
Matches the preceding subexpression 0 times or once;
d matches a numeric character, equivalent to [0-9]