站长资源网络编程

php email邮箱正则

整理:jimmy2024/10/30浏览2
简介1.验证email:< 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 a

1.验证email:

 < "/^[a-z]([a-z0-9]*[-_\.]",$email)){ 
echo “Your email address is correct!”;} 
   else{ 
echo "Please try again!"; 
} 
"htmlcode">
$str = '';
$isMatched = preg_match('/^\w[-\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14}$/', $str, $matches);
var_dump($isMatched, $matches);

匹配Email邮箱格式的正则表达式:

/^[a-z]([a-z0-9]*[-_]"htmlcode">
<"/([a-z0-9]*[-_\.]"; 
preg_match_all($pattern,$str,$emailArr); 
return $emailArr[0]; 
} 
$emailstr = "9999@qq.com.cn俺不是米vi地方就开iid邮件列表:fuyongjie@163.com 和hh@qq.com;.;;,fuyongjie.100@yahoo.com,fu-1999@sina.com"; 
$emailArr = getEmail($emailstr); 
echo "<pre>"; 
print_r($emailArr); 
echo "</pre>"; 
?> 


打印如下:
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.比较:第2里的正则里没有了第1的^和$;