Skip to content

Conversation

@mlocati
Copy link
Contributor

@mlocati mlocati commented Oct 5, 2018

In PHP 7.3, PCRE2 (the library that parses regular expressions) has been upgraded to version 10.32.

It seems that this new version of PCRE is a bit more picky when parsing regular expressions.
For example, /^[\w-:]+$ is not accepted anymore, we have this error (see https://3v4l.org/vD5O2):

Compilation failed: invalid range in character class at offset 4

The reason? - is used to represent range of characters when in square brackets (for example: [A-Z] represents a character from A to Z).
And PCRE now interprets [\w-:] as any character from \w to :, which doesn't make sense (so the error is thrown).

The solution? Just escape - with \ to tell PCRE that we actually want the character -, and not a range of characters.

@zanderwar
Copy link

Still an issue over a year later

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants