The Chinese character matching in java is [u4E00-u9FA5]. Naturally, after using this regular expression in PHP, the following error was reported:
Warning: preg_match_all():Compilation failed: PCRE does not support L, l, N {name}, U, or u at offset 6 in D:xampphtdocstestindex.php on line 7
Later I discovered that x represents hexadecimal in PHP. So I changed 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:xampphtdocstestindex.php on line 7
It seems to be another regular expression problem. Finally, just change the regular expression to [x{4E00}-x{9FA5}].
Copyright Statement: This article is an original article by the blogger and may not be reproduced without the blogger's permission.
The above introduces the matching of Chinese characters in PHP, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.