php - Why doesn't this regular expression work?
为情所困
为情所困 2017-05-16 13:15:42
0
2
401

Any Chinese letters and numbers. But why can’t I pass Chinese when I try it? It has always been no. I can pass in English. Why is this?

if(preg_match("/^[a-z0-9\xa1-\xff]{1,8}$/",$username)){
 echo "yes";
}else{
 echo "no"
}
为情所困
为情所困

reply all(2)
大家讲道理

preg_match() returns the number of matches for pattern. Its value will be 0 (no match) or 1 because preg_match() will stop searching after the first match. So aaa returning 'no' is normal.

我想大声告诉你
/^[a-z0-9\u4e00-\u9fa5]{1,8}$/

http://m.111cn.net/art-42203.htm

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template