Replace with whole match value using Notepad++ regex search and replace

The replacement can be

<sup>$0</sup>

or

<sup>$&</sup>

Note that the $0 / ${0} / $&, or even $MATCH and ${^MATCH} backrefrence inserts the whole match.

See the Substitutions section:

$&, $MATCH, ${^MATCH}
       The whole matched text.

and

$n, ${n}, \n

      Returns what matched the subexpression numbered n. Negative indices are not alowed.

Note that a match value is usually stored as Group 0 inside a match object.

However, \0 as of now does not work (Notepad++ v.6.9), it looks like it is treated as a NUL character and truncates the replacement pattern right at the location where it is located.

Leave a Comment