Replacement text

The replacement text for find-and-replace operations can contain references to capture-group text from the find. References are of the form $n, where n is the number of the capture group.

Table 55. Replacement text characters
Character Description
$n The text of the positional capture group n is substituted for $n. n must be >= 0, and not greater than the number of capture groups. A $ not followed by a digit has no special meaning, and is displayed in the substitution text as itself, a $.
\ Treat this character as a literal, suppressing any special meaning. Backslash escaping in substitution text is required only for ’$’and ’\’, but can be used on any other character without adverse effects.
$@n The text of capture group n is substituted for the regular expression that matched capture group n. n must be >= 0, and not greater than the number of capture groups. A $@ not followed by a digit has no special meaning, and is displayed in the substitution text as itself, a $@.
$#n The text of the matched capture group n is substituted for $#n. n must be >= 0, and not greater than the number of matched capture groups. A $# not followed by a digit has no special meaning, and is displayed in the substitution text as itself, a $#.