当前位置 : 主页 > 网络编程 > PHP >

验证email地址的正则表达式

来源:互联网 收集:自由互联 发布时间:2021-07-03
$email = "[emailprotected]";if (preg_match('/^[^0-9][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[@][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[.][a-zA-Z]{2,4}$/',$email)) { echo "Your email is ok.";} else { echo "Wrong email address format";}
$email = "[email protected]";
if (preg_match('/^[^0-9][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[@][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[.][a-zA-Z]{2,4}$/',$email)) {
    echo "Your email is ok.";
} else {
    echo "Wrong email address format";
}
网友评论