Home > Backend Development > PHP Tutorial > emai正则,该怎么解决

emai正则,该怎么解决

WBOY
Release: 2016-06-13 13:04:52
Original
889 people have browsed it

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'));
?>
------最佳解决方案--------------------
按照你的正则方式,邮箱改成123456@123456.com就能匹配到了。
------其他解决方案--------------------
你的@后面的\1是后向引用啊当然会出问题

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


------其他解决方案--------------------

引用:
按照你的正则方式,邮箱改成123456@123456.com就能匹配到了。
貌似@后面的还真没法确定的去匹配!如果你知道你主要匹配哪些邮箱后缀就好办
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template