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

Brendan Eich brendan at mozilla.com
Thu Jun 2 22:51:00 PDT 2011


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.

/be


More information about the es-discuss mailing list