Can anyone explain to me the differences between these two regex approaches:
/(\d)\1/
/(\d){2,}/
As far as I can see they both match for at least one recurrence of a subexpression. If they, in fact, do the same thing, are there any performance issues that distinguish them?
No they don’t do the same
matches
With the brackets you put the matched digit in a capture group and access that variable with
\1, so you match two equal digits in a row.while
matches
Here you say match two or more (
{2,}) digits in a row. This can be different digits.