Regular Expressions
Regular expressions are a powerful tool when searching and replacing text in filenames. With regular expressions you can use wildcards to match character sets, frequency operators to match repeating characters, anchors to match characters at specific locations, and backreferences to match groups of characters.
For more information on Regular Expressions, please also refer to the ICU Guide.
You can use regular expressions in the corresponding action.
Wildcards
You can use wildcards to match a set of characters.
Examples
Wildcard | Description |
---|---|
. |
Any single character. |
(hello|world) |
Either ‘hello’ or ‘world’. |
[1-6] |
Any digit between 1 and 6. |
[c-h] |
Any lowercase character between c and h. |
[D-M] |
Any uppercase character between D and M. |
[^a-z] |
Any character except any between lowercase a and z. |
[adx] |
Any one of a, d or x. |
[a-z13] |
Any lowercase character, 1, or 3. |
Frequency operators
You can use frequency operators to specify how many occurrences of a character (or wildcard) should be matched.
Examples
Operator | Occurrences |
---|---|
n* |
Zero or more of ‘n’. |
n+ |
One or more of ‘n’. |
n? |
A possible ‘n’. |
n{2} |
Exactly two of ‘n’. |
n{2,} |
Two or more of ‘n’. |
n{2,4} |
Two to four of ‘n’. |
Position anchors
You can use position anchors to match characters at the start or end of a string:
^
The pattern must be at the start of the string
$
The pattern must be at the end of the string
Groups and backreferences
You can use parentheses (…) to group expressions, and then insert the matched expression using a dollar sign $
followed by the number of the group.
Example: Search for “(Renamer [0-9]*)(Mac)”, the text is “I frequently use Renamer 7 on my Mac”:
$1 = Renamer 7 = 1st group: “(Renamer [0-9]*)” $2 = Mac = 2nd group: “(Mac)”