In the regular expression pattern, the back link to the first capture group is always \1 , not $1 .
Reason: $ means "end of line" (or end of line, depending on context) in the regular expression.
In a replacement pattern (which is not a regular expression), some dialects allow $1 (e.g. .NET, Java, Perl and JavaScript), some allow \1 (Python and Ruby), and some allow both (PHP and JGSoft).
Edit: since you wrote that you could not find the documentation on this, check out these reviews on the regular-expressions.info page:
Tim pietzcker
source share