Reputation: 384
I have seen the instructions on using $1 in order to backreference the replace, but it is not working for me. Example:
I search for
<header
to replace with
$1 class="bold"
and instead of <header class="bold"
I get $1 class="bold"
Am I missing something?
Upvotes: 0
Views: 2662
Reputation: 89557
You must understand that $n refer to the capturing group number n. Since you don't have capturing groups in your search pattern, the group number 1 doesn't exist:
You must use capturing parenthesis to define a group, example:
search: (<header)
replace: $1 class="bold"
Another example:
search: (<)(header)
replace: $1$2 class="bold"
Notice: $0
refers to the whole match (without define any capturing group). Then you can write:
search: <header
replace: $0 class="bold"
Upvotes: 4