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

Add missing `u` flag to code examples #4

Closed mathiasbynens closed 7 years ago

littledan commented 8 years ago

I think these samples are valid without /u. What is the purpose of adding it?

mathiasbynens commented 8 years ago

They won’t be in this case1:

An alternative possibility would be to only allow named capture groups in Unicode RegExps, to avoid the hazard of a user thinking they had support but not realizing that backreferences were not permitted.

With u there is no confusion.

1 I’m strongly in favor of the above option, by the way. New syntactical features should only apply to Unicode RegExps. Not using u for new regular expressions is like using var instead of const or let.

littledan commented 7 years ago

I added /u to the code samples in a separate patch; sorry for forgetting about this and not just merging it. It's best practices to use /u anyway. We're discussing the optionality of /u in https://github.com/tc39/proposal-regexp-named-groups/issues/7 .