Why does php regular expression match fail? Help regular php
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)
Reply to discussion (solution)
Preg_match ("/^ [a-zA-Z] [a-zA-Z0-9 _-] {5, 19} $/", "ml-virgil "))
Just try adding "/" before and after, why? I am a beginner in php.
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.
We often refer to "\" as "escape character" to escape some special symbols.
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. Well, let me ask you a question. I connected English and Chinese to "\ n" and saved it to mysql, php encoding and mysql are both UTF-8. Why does it find "0" in phpadmin and the data type is text? It has been bothering me for a long time...
The SQL statement is really careless. Close the post. thank you.