Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP crashes on preg_replace

Tags:

I ran the following script using php.exe:

preg_replace('#(?:^[^\pL]*)|(?:[^\pL]*$)#u','',$string);

or its equivalent:

preg_replace('#(?:^[^\pL]*|[^\pL]*$)#u','',$string);

If $string="S" or $string=" ذذ " it works, if string='ذ' it yields that is incorrect , and if string='ذذ' PHP crashes.

But it works in 4.4.0 - 4.4.9, 5.0.5 - 5.1.6 versions.

What is wrong ?

See: http://3v4l.org/T3rpV


<?php
$string='دد';
echo preg_replace('#(?:^[^\pL]*)|(?:[^\pL]*$)#u','',$string);

Output for 5.4.0 - 5.5.0alpha6

Process exited with code 139.

Output for 5.2.0 - 5.3.22, 5.5.0beta1

 

Output for 4.4.0 - 4.4.9, 5.0.5 - 5.1.6

دد 

Output for 4.3.11, 5.0.0 - 5.0.4

Warning: preg_replace(): Compilation failed: PCRE does not support \L, \l, \N, \P, \p, \U, \u, or \X at offset 7 in /in/T3rpV on line 3 

Output for 4.3.0 - 4.3.10

Warning: Compilation failed: PCRE does not support \L, \l, \N, \P, \p, \U, \u, or \X at offset 7 in /in/T3rpV on line 3