设为首页 加入收藏

TOP

preg_match(): Compilation failed: character value in \x{} or \o{} is too large at offset 8
2019-08-23 00:34:43 】 浏览:15
Tags:preg_match Compilation failed: character value too large offset

如果用正则筛选中文的时候,需要在规则后面添加字符u,表示使用utf8编码去解析

$reg = '/[\x{4e00}-\x{9fa5}]/u';

例如:

$reg = '/[\x{4e00}-\x{9fa5}]/u';

$str = '我爱你中国';
preg_match($reg, $str, $match1);
preg_match_all($reg, $str, $match2);

echo '<pre>';
var_dump($match1);
var_dump($match2);

得到的筛选结果为:

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇[PHP]算法-二进制中1的个数的PHP.. 下一篇[PHP]算法-堆排序的PHP实现

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目