Match placeholders can be used to insert search matches or match counts in the search text or replacement text.
|Placeholder||Meaning and Examples||Availability|
|The line the search match was found on.||Replacement text.|
|The number of the line the match was found on.||Replacement text.|
|The search match.||Replacement text.|
|The number of the search match. Counts the number of search matches already found. If used in the search term, %MATCHN% will be zero upon the first search attempt. If used in the replacement text, %MATCHN% will be one for the first replacement.||Search term and replacement text.|
|Search term and replacement text, but only when using regular expressions with numbered capturing groups.|
|Search term and replacement text, but only when using regular expressions with named capturing groups.|
You can add additional specifiers to all of the above placeholders. You can pad the placeholder’s value to a certain length, and control the casing of any letters in its value. The specifiers must appear before the second % sign in the placeholder, separated from the placeholder’s name with a colon. E.g. %MATCH:6L% inserts the match padded with spaces at the left to a length of 6 characters. You can add both padding and case placeholders. %MATCH:U:6L% inserts the padded match converted to uppercase.
Padding specifiers start with a number indicating the length, followed by a letter indicating the padding style. The length is the number of characters the placeholder should insert into the regular expression or replacement text. If the length of the placeholder’s value exceeds the requested length, it will be inserted unchanged. It won’t be truncated to fit the length. If the value is shorter, it will be padded according to the padding style you specified.
The L or “left” padding style puts spaces before the placeholder’s value. This style is useful for padding numbers or currency values to line them up in columns. The R or “right” padding style puts spaces after the placeholder’s value. This style is useful for padding words or text to line them up in columns. The C or “center” padding style puts the same number of spaces before and after the placeholder’s value. If an odd number of spaces is needed for padding, one more space will be placed before the value than after it.
The Z or “zero” padding style puts zeros before the placeholder’s value. This style is useful for padding sequence numbers.
Case conversion specifiers consist of a letter only. The specifier letters are case insensitive. Both “U” and “u” convert the placeholder’s value to uppercase. L converts it to lowercase, I to initial caps (first letter in each word capitalized) and F to first cap only (first character in the value capitalized). E.g. %MATCH:I% inserts the match formatted as a title.
Instead of a case conversion specifier, you can use the case adaptation specifier. It consists of A followed by a digit (not to be confused with a number followed by A, which is a padding specifier). This specifier is only available in a replacement text corresponding with a regular expression. You can use the specifier to give the placeholder the same casing style as the regular expression match or the text matched by a capturing group. Specify zero for the whole regex, or the backreference number of a capturing group. E.g. %MATCH:A2% inserts the whole regular expression match, converted to the case used by the second capturing group. The case adaptation specifier detects and adapts to uppercase, lowercase, initial caps and first cap. If the referenced capturing group uses a mixed casing style, the placeholder’s value is inserted unchanged.
Arithmetic specifiers perform basic arithmetic on the placeholder’s value. This works with any placeholder that, at least prior to padding, represents an integer number. If the placeholder does not represent a number, the arithmetic specifiers are ignored. For placeholders like %MATCH% that can sometimes be numeric and other times not, the arithmetic specifiers are used whenever the placeholder happens to represent an integer.
An arithmetic specifier consists of one or more operator and integer pairs. The operator can be +, -, *, or / to signify addition, subtraction, multiplication, or integer division. It must be followed by a positive integer. Arithmetic specifiers are evaluated strictly from left to right. When %MATCHN% evaluates to 2, %MATCHN:+1*2% evaluates to 6 because 2+1=3 and 3*2=6. Multiplication and division do not take precedence over addition and subtraction. Integer division drops the fractional part of the division’s result, so %MATCHN:/3% evaluates to 0 for the first two matches.