Footnote: Oniguruma's /g makes (...) noncapturing. It does not make (?:...) capture. When named capture is is used, (...) is automatically made noncapturing and numbered backreferences are disallowed, unless /G is used to turn (...) back into capturing groups.

-- Steven Levithan


-----Original Message----- From: Steven L.
Sent: Sunday, March 18, 2012 12:31 AM
To: [email protected] ; EcmaScript
Subject: Re: Default non-capturing regex flag [WAS: how to createstrawmanproposals?]

I'm seeing this for the first time now. Sorry for reviving old news.

On 2011-06-03, Brendan Eich wrote:

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.
[...]
As with all things RegExp, I wonder what Steve thinks.

I appreciate the vote of confidence! I consider /n to be a medium-strength
nice-to-have. In fact, I added it myself in XRegExp v2.0.0-beta. [1]

Concerns:

Kyle called this the noncapturing flag and suggested
RegExp.prototype.noncapturing. .NET calls the (?n) flag ExplicitCapture and
does not let (?: ) capture. The reason for this is suggested by the name
"explicit capture"--with /n, only explicitly named capturing groups of the
form (?<name> ) capture a value. IMHO, this is the better way to go, but of
course it's dependent on supporting named capture in the first place (as
XRegExp does).

Also IMHO, it is better to shelve /n until named capture is added.

Mike Samuel wrote:

Can RegExp flag experimentation be done in library code?

See [1].

--Steven Levithan

[1]: https://github.com/slevithan/XRegExp


_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to