ホーム > Linux > PCREでUnicode文字プロパティを使う

2010年03月01日(月曜日) 23時36分

Red Hat Entreprise Linux 5 / CentOS 5の環境で「Unicode properties」のサポートが無いので
preg_matchやpreg_replaceで\pとか使おうとするとPHP Warningが出ます。

PHP Warning: preg_replace() [function.preg-replace]: Compilation failed: support for \\P, \\p, and \\X has not been compiled at offset 16 in

確認するにはpcretest -Cで確認できます。
# pcretest -C
PCRE version 6.6 06-Feb-2006
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

「No Unicode properties support」・・・サポートしてませんね(´д`)
リビルドするのは面倒なのでできものを頂いてきました。
ここからpcre-66-27×86_64.rpmをDLしてインストール。
# wget http://gaarai.com/wp-content/uploads/2009/01/pcre-66-27x86_64.rpm
# rpm -ivh pcre-66-27x86_64.rpm
# /etc/rc.d/init.d/httpd restart

再度pcretest -Cで確認
# pcretest -C
PCRE version 6.6 06-Feb-2006
Compiled with
UTF-8 support
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

「Unicode properties support」になりました。
PHP Warningも消えたので良しとしよう(笑)

「PCREでUnicode文字プロパティを使う」 について、Twitterでつぶやく

関連記事

コメントを書く

メールアドレスは公開されません。
*」は必須項目です。

*
*

トラックバックを送る

トラックバック送信先URL
言及リンクが含まれないトラックバックは削除する場合があります。
PCREでUnicode文字プロパティを使う from りでぃすとりびゅ~しょん