hanickadot / compile-time-regular-expressions

Compile Time Regular Expression in C++
https://twitter.com/hankadusikova
Apache License 2.0
3.37k stars 186 forks source link

Unnecessary escaping of otherwise special characters in square brackets #60

Closed JohelEGP closed 5 years ago

JohelEGP commented 5 years ago

According to http://www.pcre.org/current/doc/html/pcre2pattern.html#SEC9, between [ and ]:

See example: https://godbolt.org/z/8v6cu7. It seems that you also need to escape |, even though it has no special meaning anywhere between square brackets.

The only metacharacters that are recognized in character classes are backslash, hyphen (only where it can be interpreted as specifying a range), circumflex (only at the start), opening square bracket (only when it can be interpreted as introducing a POSIX class name, or for a special compatibility feature - see the next two sections), and the terminating closing square bracket. However, escaping other non-alphanumeric characters does no harm.

hanickadot commented 5 years ago

Should be fixed now.

hanickadot commented 5 years ago

Thank you for reporting the issue.

JohelEGP commented 5 years ago

Thank you.

JohelEGP commented 5 years ago

Seems like it's not working: https://godbolt.org/z/CQEJMI

hanickadot commented 5 years ago

I removed the special case allowing [-] and [-something], currently the LL1 grammar is designed in a way which doesn't allow to fixing this, to avoid further confusion, this is no longer supported, maybe in future with a big refactoring of the grammar or parser I will revisit this.

hanickadot commented 5 years ago

I tried it, but unsuccessfully.