Home > Backend Development > PHP Tutorial > Correct PHP matching UTF-8 Chinese regular expression, _PHP tutorial

Correct PHP matching UTF-8 Chinese regular expression, _PHP tutorial

WBOY
Release: 2016-07-13 09:54:00
Original
950 people have browsed it

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);

www.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...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template