Why does php regular expression match fail? Help & lt ;? Phpif (preg_match (^ [a-zA-Z] [a-zA-Z0-9 _-] {5, 19 }$, & nbsp; abc-mmm) & nbsp; & nbsp; echo & nbsp; true; else & nbsp; echo & nbsp; false ;? & Gt; why cannot I verify the regular expression of the account for php regular expression matching? Help
If (preg_match ("^ [a-zA-Z] [a-zA-Z0-9 _ \-] {5, 19} $", "abc-mmm "))
Echo "true ";
Else echo "false ";
?>
I want to verify the regular expression of the account. it must start with a letter and can contain numbers, letters, underscores, minus signs, and 6-20. why is this expression unsuccessful?
Warning: preg_match () [function. preg-match]: No ending delimiter '^ 'found in test. php on line 3
False
Tried "^ [a-zA-Z] [a-zA-Z0-9 _-] {5, 19} $", get off "\" is not correct, please know (utf8 format)
------ Solution --------------------
It is called the delimiter. Without the delimiters, PHP determines that ^ [a-zA-Z] [a-zA-Z0-9 _-] {5, 19} $ is a string, not a variable.