Home > Backend Development > PHP Tutorial > www.hotmail.com mailbox php email mailbox regular

www.hotmail.com mailbox php email mailbox regular

WBOY
Release: 2016-07-29 08:39:02
Original
37540 people have browsed it

1. Verify email:

Copy code The code is 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 expression matching Email mailbox format:

Copy code The code is as follows:


/^[a-z]([a-z0-9]*[-_]?[a-z0-9] +)*@([a-z0-9]*[-_]?[a-z0-9]+)+[.][a-z]{2,3}([.][a-z]{2}) ?$/i;


Analysis:
/content/i constitutes a case-insensitive regular expression;
^ start of match
$ end of match
[a-z] E-Mail prefix must start with an English letter
( [a-z0-9]*[-_]?[a-z0-9]+)* matches _a_2, aaa11, _1_a_2, but does not match a1_, aaff_33a_, a__aa. If it is a null character, it will also match. * means 0 or more.
* represents 0 or more previous characters.
[a-z0-9]* matches 0 or more English letters or numbers
[-_]? matches 0 or 1 "-" because "-" Cannot appear continuously
[a-z0-9]+ matches 1 or more English letters or numbers, because "-" cannot be used as the end
@ There must be @
([a-z0-9]*[- _]?[a-z0-9]+)+ See above ([a-z0-9]*[-_]?[a-z0-9]+)* explanation, but it cannot be empty, + means one or for multiple.
[.] treats special characters (.) as ordinary characters
[a-z]{2,3} matches 2 to 3 English letters, usually com or net, etc.
([.][a-z]{2}) ? Match 0 or 1 [.][a-z]{2} (such as .cn, etc.) I don’t know if the last part of .com.cn is generally two digits. If not, please change {2} to { Starting word count, ending word count}
This regular expression used to match email addresses is relatively strong, powerful, and has wide coverage. Friends who find it useful may bookmark it.
The format of the international domain name is as follows:
The domain name is composed of any combination of specific character sets, English letters, numbers and "-" (i.e. hyphen or minus sign) in each country's language, but it cannot contain "-" or "-" at the beginning or at the end. "Cannot appear continuously. Letters in domain names are not case-sensitive. The domain name can be up to 60 bytes long (including suffixes .com, .net, .org, etc.).
/^[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;
^ Matching start
$ Matching end
[a-z] E-Mail prefix must start with an English letter
([a-z0-9]*[-_]?[a-z0-9]+)* and _a_2, aaa11 , _1_a_2 matches, but does not match a1_, aaff_33a_, a__aa. If it is a null character, it is also matched. * means 0 or more.
* represents 0 or more previous characters.
[a-z0-9]* matches 0 or more English letters or numbers
[-_]? matches 0 or 1 "-" because "-" Cannot appear continuously
[a-z0-9]+ matches 1 or more English letters or numbers, because "-" cannot be used as the end
@ There must be @
([a-z0-9]*[- _]?[a-z0-9]+)+ See above ([a-z0-9]*[-_]?[a-z0-9]+)* explanation, but it cannot be empty, + means one or for multiple.
[.] treats special characters (.) as ordinary characters
[a-z]{2,3} matches 2 to 3 English letters, usually com or net, etc.
([.][a-z]{2}) ? Match 0 or 1 [.][a-z]{2} (such as .cn, etc.) I don’t know if the last part of .com.cn is usually two digits. If not, please change {2} to { Starting word count, ending word count}
Perfect E-Mail regular expression, with detailed explanation, please help test it! 2. Extract 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 Mi vi place, just open an iid mailing list :fuyongjie@163.com and hh@qq.com;.;;,fuyongjie.100@yahoo.com,fu-1999@sina.com";
$emailArr = getEmail($emailstr);
echo "print_r($emailArr); <BR>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 regex in the second one does not have the ^ and $ in the first one;

The above introduces the regular rules of www.hotmail.com mailbox and php email mailbox, including the content of www.hotmail.com mailbox. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template