Regular expressions can be put in the online testing tool, but the echo array in the file won't work. I can match the regular expressions correctly in those regular expression testing tools, why put it in preg_match_all ('/(\ @ [a-z] + \ | [\ u4e00-\ u9fa5] + \ | [A-Z] + \ | [a-z] + \ | [a-z] + \ | [0-9] +) /is ', $ a) is not acceptable? In the test tool, I can select global search. if I do not select the test tool, I cannot. Is this the reason? Isn't preg_match_all a global search?
Reply to discussion (solution)
Several questions
1. preg_match_all (regular, string, result), you only have two parameters above
2. what is the full-width comma in your parameter segmentation?
3. change \ u to \ x
/(\ @ [A-z] + \ | [\ u4e00-\ u9fa5] + \ | [A-Z] + \ | [a-z] + \ | [a-z] + \ | [0-9] +) /is u
You must have a u modifier because you have unicode characters in the rule string.
The correct statement is as follows:
/(\ @ [A-z] + \ | [\ x {4e00}-\ x {9fa5}] + \ | [A-Z] + \ | [a-z] + \ | [a-z] + \ | [0-9] +) /isu
The correct statement is as follows:
/(\ @ [A-z] + \ | [\ x {4e00}-\ x {9fa5}] + \ | [A-Z] + \ | [a-z] + \ | [a-z] + \ | [0-9] +) /isu
Why is the final result $ res (the third parameter) a two-dimensional array with two elements, and the content of the two elements is the same?
$ Res [0] $ res [1] is the same
The correct statement is as follows:
/(\ @ [A-z] + \ | [\ x {4e00}-\ x {9fa5}] + \ | [A-Z] + \ | [a-z] + \ | [a-z] + \ | [0-9] +) /isu
Thanks for the result. I have already asked why I tested the following rule in the online testing tools before to get the correct match. I cannot put it in the file?
@ [A-z] + \ | [\ u4e00-\ u9fa5] + \ | [A-Z] + \ | [a-z] + \ | [a-z] + \ | [0-9] +
This \ u4e00-\ u9fa5 is the Chinese range of unicode encoding. it can be seen that your testing tool is in the form of a webpage
Php's regular expression engine cannot recognize this format, so it naturally cannot get the correct result.
The correct statement is as follows:
/(\ @ [A-z] + \ | [\ x {4e00}-\ x {9fa5}] + \ | [A-Z] + \ | [a-z] + \ | [a-z] + \ | [0-9] +) /isu
Thanks for the result. I have already asked why I tested the following rule in the online testing tools before to get the correct match. I cannot put it in the file?
@ [A-z] + \ | [\ u4e00-\ u9fa5] + \ | [A-Z] + \ | [a-z] + \ | [a-z] + \ | [0-9] +
Online testing or browser plug-ins use a regular expression in the js engine instead of the php engine.