Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compilation failed: unknown property name after \P

Tags:

php

pcre

Using PHP 5.3.1, PCRE is enabled and is version 7.9 2009-04-11.

$string = preg_replace("/\p{Number}/u", "", $string);

produces the error: Compilation failed: unknown property name after \P . . .

I understand this was a bug that is fixed in PHP 5.3 and up but I obviously get it as do others using my scripts. As far as I can make out, it might be something to do with the version of PCRE that is being used or how it was compiled.

I have no control over the compiled version of PHP that is being used.

  1. Is there a way to check in the PHP script if PCRE has been compiled correctly?

  2. I'm also using:

    preg_match("/\p{Lu}/u", $caseChar); preg_match("/\p{Ll}/u", $caseChar); preg_match("/\p{L}/u", $string, $caseChar);

If incorrect PCRE has been found (if 1. is possible), is there an alternative to the above preg_replace and preg_match expressions?

Thanks,

Mark

like image 212
Mark Grimshaw Avatar asked Dec 03 '25 18:12

Mark Grimshaw


1 Answers

http://php.net/manual/en/regexp.reference.unicode.php

\p{Number} is not a supported property code as per the above. It's \p{N} or even just \pN.

like image 53
Marc B Avatar answered Dec 06 '25 08:12

Marc B