html - php preg_match accept alnum and chinese characters -
i preg_match syntax to
- accept letters , numbers (numbers alone not allowed)
- disallow spaces
- disallow special characters (e.g !@#$%^&.,)
- minimum of 3 chars 12.
- allow chinese characters (can alone, or letters or numbers, or both.)
this attempted code, seemed fail goal
if(preg_match('/^[a-za-z0-9\x{4e00}-\x{9fa5}]{3,12}+$/', $nickname)) { //accepted } else { //denied }
thanks in advance.
change code below. ^(?!\d+$)
won't allow strings contain numbers.
if(preg_match('~^(?!\d+$)[a-za-z0-9\x{4e00}-\x{9fa5}]{3,12}+$~u', $nickname)) { //accepted } else { //denied }
Comments
Post a Comment