复制代码 代码如下:
^[_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3}$
复制代码 代码如下:
function is_valid_email($email, $test_mx = false)
{
if(eregi("^([_a-z0-9-]+)(.[_a-z0-9-]+)*@([a-z0-9-]+)(.[a-z0-9-]+)*(.[a-z]{2,4})[ wind_phpcode_0 ]quot;, $email))
if($test_mx)
{
list($username, $domain) = split("@", $email);
return getmxrr($domain, $mxrecords);
}
else
return true;
else
return false;
}
复制代码 代码如下:
<?php
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俺不是米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的^和$;
复制代码 代码如下:
function funcemail($str)//邮箱正则表达式
{
return (preg_match('/^[_.0-9a-z-a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,4}$/',$str))?true:false;
}//验证方法一
$str="qbcd@126.com.cn";
preg_match("/^[0-9a-z]+@(([0-9a-z]+)[.])+[a-z]{2,3}$/",$str,$re);
print_r($re);//邮箱验证二
if (eregi("^[_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3}$",$email)) {
echo "您的 e-mail 通过初步检查";
}//第三种邮箱验证方法
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!";
}
新闻热点
疑难解答