Use a regular expression to represented Chinese

xiaoxiao2021-03-05  55

Since 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:

$ Str = "Regular Expression Zhengzebiaodashi"; if (preg_match ("/ ^ [". Chr (0xA1). "-". chr (0xff). "] $ /", $ STR)) {echo "this is A pure Chinese string ";} else {echo" This is not a pure Chinese string ";

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

New Post(0)