-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Labels
Description
Motivation
I can't find a case that grouping /(.)/
can't be avoid, if used in String.match
, match[0]
can be used instead of match[1]
, if want a substitution, $&
can be used instead of $1
. Maybe I was wrong about this, but there are certainly cases we can avoid group.
Description
See above
Examples
/* ✓ GOOD */
var [matched] = foo.match(/a/);
foo.replace(/a/, '-$&');
/* ✗ BAD */
var [, matched] = foo.match(/(a)/);
foo.replace(/(a)/, '-$1');