php正则表达式匹配中文(用户名过滤)报错:Compilation failed: PCRE does not support \L, \l, \N, \U, or \u at offset 2 in
找了很多方法.都不行.
麻麻蛋的,偶然一次又可以了.记下来再说!
X试过不靠谱的方法
$preg='([\u4e00-\u9fa5_a-zA-Z0-9_]{4,10})'; 和一些各种 大括号小括号的.还是报错.√最终成功的写法:
$preg='([\x80-\xffa-zA-Z0-9_]+)';
function V_uaername($str){
//判断只允许中文.字母,数字
$preg='([\x80-\xffa-zA-Z0-9_]+)';
preg_match($preg,$str,$matchs);
echo $matchs[0];
if ($str==$matchs[0] and $str!='') {
return 1;//合法
}else{
return 0;//不合法
}
}