Home > Article > Backend Development > Regular expression code for php email verification
This article introduces the regular expression for email verification in PHP. Friends in need can refer to it.
The regular expression for php email verification is as follows: <?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); } ?> |