PHP匹配中文

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-23 13:27:331066browse

UTF-8

if(preg_match('/^[\x{4e00}-\x{9fa5}]+$/u',$str)){	echo '匹配';}else{	echo '没有匹配';}

GB2312,GBK

if(preg_match("/^[".chr(0xa1)."-".chr(0xff)."A-Za-z0-9_]+$/",$str)){	echo '匹配';}else{	echo '没有匹配';}


版权声明:本文为博主原创文章,未经博主允许不得转载。

Statement:
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
Previous article:使用 PHP 验证表单数据Next article:PHP中的流程控制