How to back reference “inner” selections ( () ) in a regular expression?

Just use \1\9 (or $1$9 in some regex implementations) like you normally would. The numbering is from left to right, based on the position of the open paren (so a nested group has a higher number than the group(s) it’s nested within).

Leave a Comment