Home >Backend Development >PHP Tutorial >How to use regular expressions to represent Chinese?
Because the Chinese ASCII code has a certain range. So you can use the following regular expression to represent Chinese.
/^[chr(0xa1)-chr(0xff)]+$/
Here 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 ";
}