php email邮箱正则

(编辑:jimmy 日期: 2024/9/25 浏览:2)

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的^和$;