note 125554 deleted from regexp.reference.meta by cmb

From: Date: Mon, 30 Nov 2020 08:51:14 +0000
Subject: note 125554 deleted from regexp.reference.meta by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-215916@lists.php.net to get a copy of this message
Note Submitter: 872140945 at qq dot com ---- php正则匹配中文的用法:\x{4e00}-\x{9fa5}; 目前由于只支持utf-8字符集; 也就是说gbk或者gb2312的字符串; 那你得先把字符串转为utf-8的,然后才能使用该方法。 另外注意,模式修饰符u不能少哦! <?php $testStr = "php是世界上最好的语言"; $ret=''; if (preg_match('#[a-z\x{4e00}-\x{9fa5}]*#iu',$testStr)) { $ret='ok'; } else { $ret = 'no'; } return $ret;

« previous php.notes (#215916) next »