You'll need to distinguish the
\1 from the following
2. A few ideas come to mind:
- Use [2] instead of 2 (a simple character class)
- Use (?:2) instead of 2 (a non-capturing paren)
- Use (?:\1) instead of \1
- Use /x mode, and insert a space
- Insert an empty non-capturing paren between the two: (?:) {grin}
-- Randal L. Schwartz, Perl hacker
update:
And these are all great solutions if we're talking about the regex part of the
substitution, but the original questioner was asking about the replacement part.
Gah.
In that case, just use ${1} instead. Shouldn't have been using \1 in the first place. {grin}