我正在编写一些 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/