php - preg_match() : Compilation failed: character value in\x{} or\o{} is too large at offset 27 on line number 25

标签 php regex preg-match

我正在编写一些 PHP 代码。在此代码中,我在 for 循环中运行 for 循环以遍历数组,然后遍历数组中当前字符串中的字符。

然后我想对当前字符串执行 preg_match() 以查看它是否匹配相当长的 RegEx。

preg_match('/[ \f\n\r\t\v\x{00a0}\x{1680}\x{180e}\x{2000-}\x{200a}\x{2028}\x{2029}\x{202f}\x{205f}\x{3000}\x{feff}]/', $input[$i][$j])

但我不断收到以下错误:

WARNING preg_match(): Compilation failed: character value in \x{} or \o{} is too large at offset 27 on line number 25

最佳答案

添加UTF-8解析,你不是UFT8模式。添加 u 参数。

preg_match('/[ \f\n\r\t\v\x{00a0}\x{1680}\x{180e}\x{2000-}\x{200a}\x{2028}\x{2029}\x{202f}\x{205f}\x{3000}\x{feff}]/u', $input[$i][$j]);

另外,我也想强调一下,你有一个错字。 \x{2000-} 应该是 \x{2000}\x{2000}-:

preg_match('/[ \f\n\r\t\v\x{00a0}\x{1680}\x{180e}\x{2000}\x{200a}\x{2028}\x{2029}\x{202f}\x{205f}\x{3000}\x{feff}]/u', $input[$i][$j]);

关于php - preg_match() : Compilation failed: character value in\x{} or\o{} is too large at offset 27 on line number 25,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32375531/

相关文章:

php - Mysql - 日期字段中的空值

php - 注意第 19 行调用堆栈上的 : Undefined variable: row in . ..uredi.php #TimeMemoryFunctionLocation

php - mysql-workbench 列行的默认值为 0 不为 NULL?

php - 替换,但仅在某些情况下包含分隔符

php - 查找哪里和哪个词匹配了sql LIKE语句

php - 将文本中的变量替换为相应的值

PHP DOM - 访问新添加的节点

php preg_match 不像在其他网络应用程序中那样工作

javascript - 获取特殊字符后没有单词的句子

PHP - preg_match_all - 有点高级