Remember that capturing groups are indexed by their opening parenthesis: you were calling the first group before it was defined.
In ((a)b)
, \1
is referring to (a)b
and \2
to a
.
To fix this, you can use the correct index:
(([a-zA-Z0-9])\2 )\1