Default non-capturing regex flag [WAS: how to create strawman proposals?]
getify at gmail.com
Thu Jun 2 22:46:47 PDT 2011
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).
The /n property would reflect on the RegExp object as `Noncapturing ==
>>>> Is there any precedent for this in other perl-based regexp packages?
>>> But more to the point of my intended proposal, .NET has the /n flag for
>>> turning off capturing for ( ) -- I'm not sure if it then turns on
>>> capturing for (?: ) or not, someone more familiar with .NET would have
>>> to inform here.
>> That's interesting. I found
>> There is no sign of non-capturing syntax (?:...) here at all. This n flag
>> seems a bit different from what you propose.
> Again, I'm not sure if .NET swaps the default behavior as I'm proposing,
> when /n is present. But it seems quite natural to me that /n would do so,
> rather than having a strange asymmetry where without the flag, both
> capturing and non-capturing are possible, but with the flag present *only*
> non-capturing is possible.
>> As with all things RegExp, I wonder what Steve thinks.
> Do you mean Steven Levithan (aka "Mr Regex")? If so, he already commented
> at length on that blog post I mentioned. I guess he implies the discussion
> is worth having by saying "...and which can be explored in future
> ECMAScript specs."
More information about the es-discuss