Take the mailbox verification, most people on the Internet write the mailbox validation regular expression code can not verify this mailbox:
i@julying.com, nor can you verify xxxxxx@i.com .
Last I found that youku.com (Youku) User registration has this problem, see figure:
Today found QQ micro-letter also has this problem:
Neither of them can verify the name of a domain name or a letter of a letter.
In my opinion, they are not intentionally not to let such a user register, but this:
A long time ago, the first programmer to write a regular was lazy, without the regular expression validation of this situation,
He might have thought it was a bit of a hassle, and maybe there was too little mail,
Did not hear a letter of the top-level domain to provide the mailbox service, also did not see that mailbox username is a letter, so did not write.
And later programmers have been using this code ...
-------------------
Because the program can not handle the location type of data, such as the 2003 network large area burst SQL injection, is a classic case.
As senior Bill Gates said: "All user input is harmful, the programmer should be as far as possible to verify all the possibilities, otherwise, the missing possibility is a potential crisis."
-------------------
I am by the way to write a complete email verification regular expression bar, later do not make such a mistake, people are very depressed.
PHP Mailbox Validation Regular expression:
Preg_match ("/^[0-9a-za-z]+@" ([0-9a-za-z]+) [.]) +[a-z]{2,4}$/i ", $email);
If more complete and rigorous validation is required, modify the regular expression.
PHP Mailbox Validation Regular expression Novice instance:
Copy Code code as follows:
<?php
function Isemail ($email) {
if (Preg_match (/^[0-9a-za-z]+@ ([0-9a-za-z]+) [.]) +[a-z]{2,4}$/i ", $email)) {
Return ' is the mailbox ';
} else{
Return ' not a mailbox ';
}
}
?>
--------------------------------------------------------------------------------
Javascript (JS) mailbox validation Regular expression:
Myreg =/^ ([a-za-z0-9]+[_|\_|\.]?) *[a-za-z0-9]+@ ([a-za-z0-9]+[_|\_|\.]?) *[a-za-z0-9]+\. [A-za-z] {2,4}$/;
This can be verified in the form of: i@julying.com, i@i.com such mailboxes
--------------------------------------------------------------------------------
Javascript (JS) mailbox validates the regular expression novice instance:
Copy Code code as follows:
<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 a mailbox ';
Return ' is the mailbox ';
};
Alert (Isemail (' i@julying.com '));
</script>