Renamer Icon

About 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.

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]A number between 1 and 6
[c-h]A lower case character between c and h
[D-M]An upper case character between D and M
[^a-z]Absence of lower case a to z
[adx]One of the characters a, d or x
[a-z13]a lower case character or 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,}At least 2 or more of 'n'
n{2,4}From 2 to 4 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 parenthesis (...) 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 Renamer4Mac":

$1= Renamer4 = 1st group: "(Renamer[0-9]*)"
$2= Mac = 2nd group: "(Mac)"

Related Topics

regular expressions