1. Verify Email:
Copy the Code code as follows:
< PHP
if (Ereg ("/^[a-z") ([A-z0-9]*[-_\.]? [a-z0-9]+] *@ ([a-z0-9]*[-_]?[ a-z0-9]+) +[\.] [A-z] {2,3} ([\.] [A-z] {2})? $/i; ", $email)) {
echo "Your email address is correct!";}
else{
echo "Please try again!";
}
?>
Regular expressions that match the email format:
Copy the Code code as follows:
/^[a-z] ([a-z0-9]*[-_]?[ a-z0-9]+) *@ ([a-z0-9]*[-_]?[ a-z0-9]+) +[\.] [A-z] {2,3} ([\.] [A-z] {2})? $/i;
Analytical:
/content/I forms a case-insensitive regular expression;
^ Match start
$ match End
[A-z] e-mail prefix must be an English letter beginning
([A-z0-9]*[-_]? [a-z0-9]+] * and _a_2, AAA11, _1_a_2 match, and A1_, Aaff_33a_, A__aa do not match, if it is a null character, is also matched, * represents 0 or more.
* Represents 0 or more of the preceding characters.
[a-z0-9]* matches 0 or more English letters or numbers
[-_]? Match 0 or 1 "-" because "-" cannot appear continuously
[a-z0-9]+ matches 1 or more English letters or numbers, because "-" cannot be the end
@ must have a @
([A-z0-9]*[-_]? [a-z0-9]+] + see above ([a-z0-9]*[-_]?[ a-z0-9]+) * explanation, but cannot be empty, + denotes one or more.
[\.] The special character (.) As ordinary characters
[A-z] {2,3} matches 2 to 3 English letters, typically COM or net.
([\.] [A-z] {2})? Match 0 or 1 [\.] [A-z] {2} (such as. cn, etc.) do not know the general. Com.cn the last part is not all two-bit, if not please modify {2} to {start Word, end Word}
This is used to match the regular expression of the mailbox, or relatively strong, powerful, broad coverage, useful to the collection of friends.
The international Domain name format is as follows:
A domain name is made up of any combination of specific character sets, English letters, numbers, and "-" (that is, hyphens or minus signs) of each country's characters, but neither the beginning nor the end can contain "-", "-" cannot appear continuously. The letters in the domain name are not case-sensitive. The domain name can be up to 60 bytes long (including suffix. com,. NET,. org, and so on).
/^[a-z] ([a-z0-9]*[-_]?[ a-z0-9]+) *@ ([a-z0-9]*[-_]?[ a-z0-9]+) +[\.] [A-z] {2,3} ([\.] [A-z] {2})? $/i;
/content/I forms a case-insensitive regular expression;
^ Match start
$ match End
[A-z] e-mail prefix must be an English letter beginning
([A-z0-9]*[-_]? [a-z0-9]+] * and _a_2, AAA11, _1_a_2 match, and A1_, Aaff_33a_, A__aa do not match, if it is a null character, is also matched, * represents 0 or more.
* Represents 0 or more of the preceding characters.
[a-z0-9]* matches 0 or more English letters or numbers
[-_]? Match 0 or 1 "-" because "-" cannot appear continuously
[a-z0-9]+ matches 1 or more English letters or numbers, because "-" cannot be the end
@ must have a @
([A-z0-9]*[-_]? [a-z0-9]+] + see above ([a-z0-9]*[-_]?[ a-z0-9]+) * explanation, but cannot be empty, + denotes one or more.
[\.] The special character (.) As ordinary characters
[A-z] {2,3} matches 2 to 3 English letters, typically COM or net.
([\.] [A-z] {2})? Match 0 or 1 [\.] [A-z] {2} (e.g.. CN, etc.) I don't know the general. Com.cn the last part is not all two-bit, if not please modify {2} to {start Word, end Word}
Perfect e-mail regular expression, with detailed explanation, please help test it! 2. Extract the email from the string:
function Getemail ($STR) {
$pattern = "/([a-z0-9]*[-_\.]? [a-z0-9]+] *@ ([a-z0-9]*[-_]?[ a-z0-9]+) +[\.] [A-z] {2,3} ([\.] [A-z] {2})? /I ";
Preg_match_all ($pattern, $str, $EMAILARR);
return $EMAILARR [0];
}
$emailstr = "9999@qq.com.cn I am not a M VI place on the IID mailing list: fuyongjie@163.com and hh@qq.com;. ;;, fuyongjie.100@yahoo.com,fu-1999@sina.com ";
$EMAILARR = Getemail ($EMAILSTR);
echo "
echo "
";
?>
Print as follows:
Array
(
[0] = 9999@qq.com.cn
[1] = fuyongjie@163.com
[2] = hh@qq.com
[3] = fuyongjie.100@yahoo.com
[4] = fu-1999@sina.com
)
3. Comparison: The 2nd in the regular there is no 1th ^ and $;
The above describes the www.hotmail.com email PHP email mailbox Regular, including the contents of the www.hotmail.com mailbox, I hope that the PHP tutorial interested in a friend helpful.