Home > Backend Development > PHP Tutorial > How to use regular expressions_PHP tutorial

How to use regular expressions_PHP tutorial

WBOY
Release: 2016-07-13 10:53:49
Original
1018 people have browsed it

Because Chinese ASCII codes have a certain range. So you can use the following regular expression to represent Chinese.
/^[chr(0xa1)-chr(0xff)]+$/
The following is an example of usage:
$str = "Beyond PHP";
if (preg_match("/^ [".chr(0xa1)."-".chr(0xff)."]+$/", $str)) {
     echo "This is a pure Chinese string";
} else {
echo "This is not a pure Chinese string";
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632389.htmlTechArticleBecause the Chinese ASCII code has a certain range. So you can use the following regular expression to represent Chinese. /^[chr(0xa1)-chr(0xff)]+$/ The following is an example of use: $str = "Super...
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