On Tue, 31 Dec 2013, Bruno wrote:
> Consider testing this expression with pcretest :
> /[^._=-\w]+/
>
> With pcre 8.34 :
> re> /[^._=-\w]+/
> Failed: invalid range in character class at offset 7
If Perl is run with the -w (warn) option, this pattern gives:
False [] range "=-\w" in regex; marked by <-- HERE in m/[^._=-\w <--
HERE ]+/ at (eval 1) line 1, <INFILE> line 1.
It does, however, go on to match something; I think it treats the hyphen
as a literal.
PCRE does not have a warning mode for compiles; it either succeeds or
gives an error. I thought that the previous behaviour of silently
turning the hyphen into a literal was a bad idea, so I instituted the
error.
> preg_replace warns me with the message «invalid range...» and returns an
> empty string when using libpcre version 8.34. So it breaks the application
> logic.
I don't use PHP, but it seems to me that PHP ought to treat a PCRE
compile-time error more seriously. What does it do with other pattern
errors, for example /[abc/ (which has a missing ])?
> PS : Today, there is not 8.34 option in the version listbox on this page.
There is now. Sorry about that; it's even on my list of "things you must
do when making a new release" but somehow I overlooked it.