escaping - in /u RegExp

Mathias Bynens mathias at
Wed Jan 14 00:20:32 PST 2015

> On 13 Jan 2015, at 22:23, Allen Wirfs-Brock <allen at> wrote:
> Would those of you who consider yourselves RegExp experts take a look at  Is this a bug? If so, what is the fix?
> This construction for Identity Escape goes back to Norbert's original proposal 
> Perhaps we need to add a:
>   ClassAttom[U] :: [+U]  \-
> production or some such to the pattern grammar.

I think it’s a bug — see for the discussion that led to this report.

Your change would allow developers to use an escaped `-` in a character class, e.g. `/[a-f\-A-Z]/u`, rather than having to move it to the beginning (i.e. `/[-a-fA-Z]/u` or end (`/[a-fA-Z-]/u`) of the character class, as is possible today without the `u` flag. That is a good thing IMHO.

More information about the es-discuss mailing list