2012-04-04 82 views
1

preg_match("/\b(word1|word2)\b/iu", 'text text text word1 text text');的preg_match UTF-8的問題

出於某種原因,上面的代碼不會與希伯來文字符中的一個服務器上運行,但會在另外一個工作。可能是什麼原因?

回答

0

你有perl兼容正則表達式(PCRE)與Unicode支持啓用的屬性?那將是我的猜測。

+0

爲了找到答案,在shell - 型'pcretest -C '它會告訴你是否啓用了unicode屬性支持。 – 2012-04-04 20:45:37

+0

編譯爲 UTF-8支持 Unicode屬性支持 – Lior 2012-04-04 20:49:30

+0

在兩臺服務器上? – 2012-04-04 20:51:32

-1

嘗試preg_match(「/ \ b(word1 | word2)\ b/iu」,utf8_decode('text text text1 text text'));

+1

這不會解決問題。 – 2012-04-04 20:46:18

0

您需要Perl兼容的正則表達式(PCRE)3.9版本,至少你的服務器上能夠有UTF-8字符圖案preg_match()功能