Default non-capturing regex flag [WAS: how to create strawman proposals?]

Juriy Zaytsev kangax at gmail.com
Fri Jun 3 10:49:35 PDT 2011


On Fri, Jun 3, 2011 at 1:51 AM, Brendan Eich <brendan at mozilla.com> wrote:

> On Jun 2, 2011, at 10:49 PM, Brendan Eich wrote:
>
> > On Jun 2, 2011, at 10:46 PM, Kyle Simpson wrote:
> >
> >> I propose a /n flag for regular expressions, which would swap the
> default capturing/non-capturing behavior between ( ) and (?: ) operators
> (that is, ( ) would not capture, and (?: ) would capture).
> >
> > I like it. No worries about the .NET somewhat different flag.
>
> There's no backward compatibility fear, because unknown flags (from the
> future, so to speak) cause errors:
>
> Error: invalid regular expression flag n
> Source File: javascript:alert(/hi/n)
> Line: 1, Column: 10
> Source Code:
> alert(/hi/n)
>
> Error: invalid regular expression flag n
> Source File: javascript:alert(new%20RegExp("hi",%20"n"))
> Line: 1
>
> Tested in Firefox 4, copied from Error console.
>

Chrome (13) and Safari (5) tolerate "n". No error.

Opera 11.10 throws for "n" but not so for all the flags. It's silent for "x"
(but it supports "x" so that's understandable) and "y" (support for which
was dropped earlier, but silent compilation seems to remain).

-- 
kangax
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110603/29fa4baa/attachment-0001.html>


More information about the es-discuss mailing list