The correct PHP regular expression to match UTF-8 Chinese,
I have been using this before
Copy code The code is as follows:
preg_match('~[x7f-xff] ~is', $string, $tmp);
I just discovered today that the above will also match characters from some European countries
You should use the following one, pay attention to the modifier u
Copy code The code is as follows:
preg_match('~[x{4e00}-x{9fa5}] ~u', $string, $tmp);
http://www.bkjia.com/PHPjc/998806.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/998806.htmlTechArticleThe correct PHP matching UTF-8 Chinese regular expression, I have been using this to copy the code. The code is as follows: preg_match ('~[x7f-xff] ~is', $string, $tmp); I just discovered today that the above one is also...
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn