In contrast to the rather complex match pattern, the replace pattern is very simple. There is only one special character, the dollar sign ($). Every other character will be replaced as-is. If you want to insert an actual dollar sign you will need to escape it with another one (so $$ will insert one dollar sign). In addition to plain text, you can use special variables to insert dynamic text.
If you have captured text in the match pattern using (...) (an unnamed capture) or (?<foo>...) (a named capture), that text will be stored in a variable that you can use in the replace pattern.
To insert the contents of an unnamed capture simply type $n at the position you want the text to appear, where n is the number of the capture (you can use $nn only if you have 10 or more captures). If you want to follow a unnamed capture replacement by an actual number, you will need to use ${n} instead to prevent it from assuming the following number is part of the capture number.
To insert the contents of a named capture use the same syntax: ${name}, where name is the name if the capture you specified in the match pattern. Note that you must use the curly brackets with named captures.
In addition to the variables you create yourself through captures, there are several others that are automatically made available for you to use. The most common is $0 which contains all the text matched by your match pattern (ie, if the replace pattern contained only this, the result would be the same as the original filename). This comes in handy, for example, when you don’t actually want to change the filename but want to apply a Change Case transformation on part of it.
Other common variables include:
the text before the match, if any (before $0) | |
the text after the match, if any (after $0) | |
the entire original filename (the same as $`$0$') |
There is one other special variable that isn’t actually part of regular expressions, but RegexRenamer supports directly: $#. This variable will be replaced with a number that is incremented for each file, according to the settings in the Numbering menu.