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:53:44
Original
998 people have browsed it

Correct PHP matching UTF-8 Chinese regular expression

This article mainly introduces the correct PHP matching UTF-8 Chinese regular expression. This article provides a comparison There are two different regular expressions. Friends who need them can refer to them

I have been using this before

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

The code is as follows:

preg_match('~[x{4e00}-x{9fa5}] ~u', $string, $tmp);

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1000090.htmlTechArticleCorrect PHP matching UTF-8 Chinese regular expression This article mainly introduces the correct PHP matching UTF- 8 Chinese regular expressions. This article compares two different regular expressions. The required...
Related labels:
php
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