tc39 / proposal-regexp-named-groups

Named capture groups for JavaScript RegExps
https://tc39.github.io/proposal-regexp-named-groups/
222 stars 21 forks source link

Enable named capture groups with a new RegExp flag #3

Closed pgilad closed 7 years ago

pgilad commented 8 years ago

instead of allowing them only in unicode regex, and to ensure backwards compatibility, the named capture groups can be turned on via a new RegExp flag

Maybe /k ?

littledan commented 8 years ago

Interesting suggestion. Would you need this flag if you use a Unicode RegExp?

mathiasbynens commented 8 years ago

I strongly disagree with this suggestion. Introducing new flags has a cost, and should only be done when absolutely necessary. RegExps with the u flag set can be extended with new syntax in a backwards compatible way already, so no new flag is needed.

instead of allowing them only in unicode regex

Why would you not want to use the u flag for new regular expressions?

pgilad commented 8 years ago

I suggested it because according to author this cannot be used safely (without breaking backwards compat.) with non-unicode regexp, but if everyone intends to use the u flag then another new flag is redundant

littledan commented 7 years ago

I don't think we'll use a new flag; we'll probably use one of the options described at https://github.com/tc39/proposal-regexp-named-groups/issues/7