You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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');
The text was updated successfully, but these errors were encountered:
Motivation
I can't find a case that grouping
/(.)/
can't be avoid, if used inString.match
,match[0]
can be used instead ofmatch[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
The text was updated successfully, but these errors were encountered: