How to use a regular expression to represent Chinese

xiaoxiao2021-03-06  42

Since the Chinese ASCII code has a certain range. So you can represented Chinese with the following regular expressions.

/ ^ [CHR (0xA1) -Chr (0xFF)] $ /

Here is an example of use:

$ Str = "Beyond PHP"; if (preg_match ("/ ^ [". "-". chr (0xff). "] $ /"] / ", $ str) {echo" This is a pure Chinese string ";} else {echo" This is not a pure Chinese string ";

转载请注明原文地址:https://www.9cbs.com/read-60912.html

New Post(0)