notepad++ Referencing Capture Groups


Example

Backreferences

"Backreferences" are references in a search regex to capture groups in the same search regex. The "search regex" is the regex used in the "Find" field of the Find/Replace dialog box. Here is the most common backreference syntax:

Absolute:  (group one)...\1

Relative:  (group one)(group two)...\-1

Named:     (?<name>group)...\k<name>

Substitutions

"Substitutions" are references in a replacement regex to capture groups in the associated search regex. The "replacement regex" is the regex used in the "Replace" field of the Find/Replace dialog box. Here is the most common substitution syntax:

Absolute:  $1

Named:     $+{name}

More Than 9 Groups

The formats \1, \-1, and $n are limited single-digit numbers. In order to positionally reference a capture group greater than nine, use the following syntax instead:

Backreference:  (group one)...(group ten)...\g{10}

Substitution:   ${10}