Preg_replace + UTF-8 does not work on one server, but works on another

echo preg_match("/\b(בדיקה|מילה)\b/iu", "זוהי בדיקה");

For some reason, this code returns 1 on several servers that I tested on, but 0 on one specific server.

PCRE is compiled with UTF-8 support and support for Unicode properties. What could be the problem?

+5
source share
2 answers

There may be a difference between the versions of PCRE that PHP uses.

PHP and PCRE versions: http://php.net/pcre.installation

You should use 8.10+ (PHP 5.3.4 +)

Version 8.10 25-Jun-2010:

  • PCRE_UCP \b,\d,\s,\w POSIX. Unicode. (* UCP) . pcretest /W . REG_UCP, POSIX.

Edit: , 1 PHP 5.3.10 0 PHP 5.3.2 PHP 5.3.3.

+2

PCRE lib. - , "UCP verb": preg_match('/(*UCP)\b(בדיקה|מילה)\b/iu', 'זוהי בדיקה').

PCRE v8.10, PHP 5.3.4 --with-pcre-regex=DIR.

Ref ( )

+1

All Articles