Home > Backend Development > PHP Tutorial > 为何[u4e00-u9fa5]不能匹配中文

为何[u4e00-u9fa5]不能匹配中文

WBOY
Release: 2016-06-13 12:49:24
Original
1397 people have browsed it

为什么[\u4e00-\u9fa5]不能匹配中文
用php的preg_match()函数匹配中文的时候,
匹配规则这么写,

$rule ='/[\u4e00-\u9fa5]/';
Copy after login

编译出错,说不知道\u,
该怎么办?
php怎么匹配utf-8编码的中文和gb2312编码的中文??

正则表达式
------解决方案--------------------
/[\x{4e00}-\x{9fa5}]/u
字符串需要unicode
------解决方案--------------------
gbk 和 utf-8是不一样的...utf-8很轻松的就可以匹配了...
------解决方案--------------------
你的php文件自身是gbk编码
或者charset没有设为utf-8
------解决方案--------------------
你的php文件不是utf-8编码
------解决方案--------------------
谁让你要所谓“国际化”呢?
中国第一!gbk 无所不能
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template