Both of these work just fine in Chrome, Safari, and Firefox:
- Code: Select all
This is because a character class is itself already "escaped." That's why you don't need to escape parentheses or bar characters either, but you do have to escape the close-bracket ( ] ) character to treat it as part of the character class. The regex parser doesn't care about slashes being delimiters until the character class has exited.
So what is needed is a different set of considerations for the way characters (perhaps just unescaped slashes) are interpreted inside bracketed character classes, and special treatment for \] - so that it doesn't break out of 'character class mode.'