php email validation regular and Detailed

What are the current mailbox format // 1. The first type is the QQ mailbox, its extension is, QQ @, .com.
// 2. No. 2 is NetEase mailbox extension is, @ 163.com or @ 126.com
// 3. No. 3 is Yahoo mail, file extensions, @ yahoo.cn
// 4. a fourth Sina-mail, file extensions sina.com @
// 5. a fifth Sohu mailbox, suffix shouhu.com name is @
// 6. Microsoft is the sixth-mail, file extensions, @ Outlook.com
// 7. a seventh is Google mail, name suffix is @ gmail.com

It can be obtained according to the prior step of mailbox format
// 1) mailbox is confirmed and the end of the intermediate @ symbol
match between 2-7 alphanumeric matching three or more underscore before @ @ .com and 2) @ symbol bit letters or three digits. Finally, at the end may also be .cn


$pattern = '/^\w{3,}@([a-z]{2,7}|[0-9]{3})\.(com|cn)$/';
$subject = '[email protected]';
echo preg_match_all($pattern, $subject, $matches);

Guess you like

Origin www.cnblogs.com/wyqn/p/11775360.html