本文介绍下,php进行邮箱验证的正则表达式,有需要的朋友,可以参考下。
php邮箱验证的正则表达式,如下: <?php /** * 邮箱地址正则表达式 * edit bbs.it-home.org */ $preg = '/^(\w{1,25})@(\w{1,16})(\.(\w{1,4})){1,3}$/'; $b = 'ffgddayasdadasdf@gmialsdfsdfasd3.com.cn.org'; if(preg_match($preg, $b)){ echo "匹配到了"; }else{ echo "没有匹配到"; } //邮箱正则验证 示例2 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!”; } //邮箱正则验证 示例3 function checkEmail($email) { $pregEmail = "/([a-z0-9]*[-_\.]?[a-z0-9]+)*@([a-z0-9]*[-_]?[a-z0-9]+)+[\.][a-z]{2,3}([\.][a-z]{2})?/i"; return preg_match($pregEmail,$email); } ?> Salin selepas log masuk |