問題描述
我正在嘗試在我的網站上運行正則表達式,但收到以下響應:
I am attempting to run a regex on my site, and I am getting this response:
編譯失敗:支持P,p 和 X 尚未編譯偏移量 1
Compilation failed: support for P, p, and X has not been compiled at offset 1
在谷歌上搜索了一下之后,我發現我服務器上的 PCRE 顯然沒有啟用 UTF8,因此導致了問題.當我使用 pcretest -C ssh 時,我得到
After googling for a bit, I've found that apparently my PCRE on my server is not UTF8 enabled, and is therefore causing problems. When I ssh with pcretest -C I get
PCRE 6.6 版 2006 年 2 月 6 日
PCRE version 6.6 06-Feb-2006
編譯支持UTF-8 否Unicode 屬性支持換行字符為 LF 內部鏈接大小 =2 POSIX malloc 閾值 = 10
默認匹配限制 = 10000000
默認遞歸深度限制 =10000000 匹配遞歸使用堆棧
Compiled with UTF-8 support No Unicode properties support Newline character is LF Internal link size = 2 POSIX malloc threshold = 10
Default match limit = 10000000
Default recursion depth limit = 10000000 Match recursion uses stack
當我執行 yum update pcre 時,它??告訴我沒有任何東西可以更新.
When I do yum update pcre it tells me that there isn't anything to update.
人們告訴我我可以打開 UTF-8 支持...幫助?
People are telling me that I can turn on UTF-8 support...help?
我是菜鳥.
推薦答案
有一個關于為 pcre 重建 RPM 的很好的教程 這里.
There's a good tutorial on rebuilding the RPM for pcre here.
如果您向下滾動到更新的 RPM 文件...",您會發現一些預先構建的 RPM,如果您只是想讓它工作(記住在完成后重新啟動 Apache,而不僅僅是正常的重新加載).
If you scroll down to "Updated RPM file for..." you'll find some pre-built RPM's if you just want it to work (remember to restart Apache after you're done, not just a graceful reload).
tl;dr 版本是:用 --enable-utf8
和 --enable-unicode-properties
The tl;dr version is: recompile pcre with --enable-utf8
and --enable-unicode-properties
這篇關于PHP PCRE(正則表達式)不支持 UTF-8?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!