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

emai正则,该怎么解决

WBOY
WBOYOriginal
2016-06-13 10:58:58802browse

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

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


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

引用:
按照你的正则方式,[email protected]
[email protected]!如果你知道你主要匹配哪些邮箱后缀就好办
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