求用户注册时php正则表达式验证 1、用户名:5-20位,字母、数字、汉字或下划线组成。 2、密码:6—20位,由字母、数字组成 3、昵称:2-20位,由字母、数字、汉字组成 4、email验证注意:是php的哈,不是JavaScript的 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 preg_match("/[\w_\x7f-\xff\]{5,20}/i",$str)preg_match("/[\w]{6,20}/i",$str);preg_match("/[\w\x7f-\xff\]{2,20}/i",$str)preg_match("/[\w_\x7f-\xff\]/i",$str)preg_match("/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/", $str) preg_match("/[\w_\x7f-\xff\]{5,20}/i",$str)preg_match("/[\w]{6,20}/i",$str);preg_match("/[\w\x7f-\xff\]{2,20}/i",$str)preg_match("/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/", $str) 刚看到帖就有人回复了, 有一个email验证的我不同意preg_match("/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/", $str)1 域名中能用 “+” 这个?2 域名后缀,即 “@” 之后不能匹配中文域名 有这个错误啊,怎么办?Warning: preg_match() [function.preg-match]: Compilation failed: missing terminating ] for character class at offset 有这个错误啊,怎么办? Warning: preg_match() [function.preg-match]: Compilation failed: missing terminating ] for character class at offset preg_match("/^[a-z]([a-z0-9])+@([a-z0-9])+[\.][a-z]{2,3}$/",$email) jakey9826 ,您好啊,你给的正则第1、3个有警告信息啊,Warning: preg_match() [function.preg-match]: Compilation failed: missing terminating ] for character class at offset 14 in D:\work\Apache2.2\htdocs\test.php on line 3是不是php不支持这种写法,希望得到解答,立马结账!谢谢。 系统函数preg-match,没有使用吧。。 不知道合不合你的要求! 刚才写的! 编码是 UTF-8 if($_POST){ $reg_Id = $_POST['id']; $reg_Pwd = $_POST['pwd']; $reg_Email = $_POST['email']; $pcre_Id = '/^[\x{4e00}-\x{9fa5}a-zA-Z0-9_]{5,20}$/u'; $pcre_Pwd = '/^[0-9a-zA-Z]{6,20}$/'; $pcre_Email = '/^[a-zA-Z][0-9a-zA-Z_]+@([0-9a-zA-Z][0-9a-zA-Z.]{0,30}\.)[a-zA-Z]{2,4}$/'; if(preg_match($pcre_Id,$reg_Id)){ echo '用户名匹配'."<BR>"; }else{ echo '用户名不匹配'."<BR>"; } if(preg_match($pcre_Pwd,$reg_Pwd)){ echo '密码匹配'."<BR>"; }else{ echo '密码不匹配'."<BR>"; } if(preg_match($pcre_Email,$reg_Email)){ echo '邮箱匹配'."<BR>"; }else{ echo '邮箱不匹配'."<BR>"; } }?><form name="form1" method="POST" action="">用户名:<input type="text" name="id" id="id" />密 码:<input type="password" name="pwd" id="pwd" />邮 箱:<input type="text" name="email" id="email" /><input type="submit" name="sub" id="sub" value="验证" /></form> [分享]基于mysql的分页程序完全解决方案(含普通分页/分段分页/原始分页/微博的since_id类分页) phpw网站源码下载后 PHP-GTK真的还是在玩具时代吗? 高分:找懂PHP的帮忙翻译下代码成asp.net ffmpeg 运行的问题 php5 是否存在mysqli_pconnect() 这个函数? 不同php服务器页面验证 一個排序的問題 求助!关天排列方式........ MYSQL数据备份分析,大家看看我这样子备份会不会有问题。 7948162群欢迎你 linux下让php支持gd2 急啊~~~
preg_match("/[\w]{6,20}/i",$str);
preg_match("/[\w\x7f-\xff\]{2,20}/i",$str)
preg_match("/[\w_\x7f-\xff\]/i",$str)
preg_match("/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/", $str)
preg_match("/[\w]{6,20}/i",$str);
preg_match("/[\w\x7f-\xff\]{2,20}/i",$str)
preg_match("/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/", $str)
preg_match("/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/", $str)1 域名中能用 “+” 这个?2 域名后缀,即 “@” 之后不能匹配中文域名
Warning: preg_match() [function.preg-match]: Compilation failed: missing terminating ] for character class at offset
Warning: preg_match() [function.preg-match]: Compilation failed: missing terminating ] for character class at offset
是不是php不支持这种写法,希望得到解答,立马结账!谢谢。
编码是 UTF-8 if($_POST){
$reg_Id = $_POST['id'];
$reg_Pwd = $_POST['pwd'];
$reg_Email = $_POST['email'];
$pcre_Id = '/^[\x{4e00}-\x{9fa5}a-zA-Z0-9_]{5,20}$/u';
$pcre_Pwd = '/^[0-9a-zA-Z]{6,20}$/';
$pcre_Email = '/^[a-zA-Z][0-9a-zA-Z_]+@([0-9a-zA-Z][0-9a-zA-Z.]{0,30}\.)[a-zA-Z]{2,4}$/';
if(preg_match($pcre_Id,$reg_Id)){
echo '用户名匹配'."<BR>";
}else{
echo '用户名不匹配'."<BR>";
}
if(preg_match($pcre_Pwd,$reg_Pwd)){
echo '密码匹配'."<BR>";
}else{
echo '密码不匹配'."<BR>";
}
if(preg_match($pcre_Email,$reg_Email)){
echo '邮箱匹配'."<BR>";
}else{
echo '邮箱不匹配'."<BR>";
}
}?>
<form name="form1" method="POST" action="">
用户名:<input type="text" name="id" id="id" />
密 码:<input type="password" name="pwd" id="pwd" />
邮 箱:<input type="text" name="email" id="email" />
<input type="submit" name="sub" id="sub" value="验证" />
</form>