I've a PHP library that uses a number of regular expressions featuring the P
expressions for multibyte strings, e.g.
((((?:P{M}p{M}*)+?)|('[^']*')|("[^"]*"))!)?$?([a-z]{1,3})$?(d+)
While this works on most builds, I've had a few reports of the regexp returning an error.
Depending on Operating platform, the error messages from PCRE are:
Compilation failed: PCRE does not support L, l, N, P, p, U, u, or X at offset n
or
Compilation failed: support for P, p, and X has not been compiled at offset n
I know that I can probably test a regexp at the beginning of my code that uses P
, and trap for a returned error, then use that response to set a compatibility flag and provide a degraded (non UTF-8) regexp without the P
within the main body of my code based on that compatibility flag.
I was wondering if there was any simpler way to identify whether PCRE had been built without the --enable-unicode-properties
or --enable-utf8
configuration switches. PHP provides access to PCRE_VERSION
constant, but that won't help identify whether P
support is enabled or not.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…