<?php /** * 邮箱地址正则表达式 */ $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); } ?>
php使用正则验证邮箱
阅读:3813 输入:2015-03-27 18:29:02
- 上一篇:php用正则判断手机号码
- 下一篇:php过滤垃圾留言(评论)信息的方法