php - eregi to pregmatch not working -
how change not alphanumeric? (on google see want alphanumeric)
code :
/* check if username not alphanumeric */ else if(!preg_match("/^[a-za-z0-9,]+$/", $subuser)){ $form->seterror($field, "* username not alphanumeric"); }
it keeps saying
* username not alphanumeric
this old part when had eregi
/* check if username not alphanumeric */ else if(!eregi("^([0-9a-z])+$", $subuser)){ $form->seterror($field, "* username not alphanumeric"); }
easist way regex use ^
inside []
character class negate it:
if(preg_match('/[^a-z0-9]/i', $subuser)) { //contains @ least 1 non alpha-num character. }
however, php supplies built-in function this: ctype_alnum()
if(!ctype_alnum($subuser)) { .... }
Comments
Post a Comment