Home >Backend Development >PHP Tutorial > emai正则,该怎么处理

emai正则,该怎么处理

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-13 13:00:31872browse

emai正则
这样写怎么匹配不了邮件
function check($str){
$re='/([a-z0-9_-]+)@\1(\.[a-z0-9_-])+/i';
preg_match($re,$str,$result);
return $result;
}
var_dump(check('123456@qq.com'));
?>
------解决方案--------------------
你的@后面的\1是后向引用啊当然会出问题

$re='/([a-z0-9_-]+)@([a-z0-9_-]+)(\.([a-z0-9_-])+)+/i';


------解决方案--------------------
按照你的正则方式,邮箱改成123456@123456.com就能匹配到了。
------解决方案--------------------

引用:
按照你的正则方式,邮箱改成123456@123456.com就能匹配到了。
貌似@后面的还真没法确定的去匹配!如果你知道你主要匹配哪些邮箱后缀就好办
Statement:
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