: This article describes how PHP matches Chinese characters. if you are interested in the PHP Tutorial, refer to it. In java, the Chinese character match is [\ u4E00-\ u9FA5]. if you use this regular expression in PHP, the following error is reported:
Warning: preg_match_all (): Compilation failed: PCRE does not support \ L, \ l, \ N {name}, \ U, or \ u at offset 6 in D: \ xampp \ htdocs \ test \ index. php on line 7
In PHP, \ x indicates hexadecimal. Change the regular expression to [\ x4E00-\ x9FA5], but the following error will still be reported:
Warning: preg_match_all (): Compilation failed: invalid UTF-8 string at offset 9 in
D: \ xampp \ htdocs \ test \ index. php on line 7
It seems to be a regular expression problem again. finally, change the regular expression to [\ x {4E00}-\ x {9FA5.
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.
The above section describes how to match Chinese characters in PHP, including related content, and hope to help those who are interested in PHP tutorials.