PFrank Regular Expression Quick Reference

Search pattern

With PFrank, search patterns will match as many occurences of the pattern as possible in a filename (in standard regex terminology that would be the same as applying the 'global' or 'g' switch to the pattern).

Special characters

. ? + * ^ $ \
( ) [ ] { } |
Need to be escaped with a backslash (\) to match the actual character
e.g. The search pattern '\+' matches the '+' character in '123454321+FIVEfiveF'.

. Matches one of any character
e.g. The search pattern '.3' matches the '23' and '43' strings in '123454321+FIVEfiveF'.
(...|...|...) Matches one of the alternatives
e.g. The search pattern '(5|FIVE)' matches the '5' and 'FIVE' strings in '123454321+FIVEfiveF'.

Character classes

[abc] Matches any character within the brackets (same as (a|b|c))
[^abc] Matches any character not between the brackets.
e.g. The search pattern '[^12FI]' matches all string in '123454321+FIVEfiveF' except the '12', '21', 'FI', and 'F' portions.

\d Matches digits (same as [0-9])
\D Matches non-digits (same as [^0-9])
\w Matches alphanumeric (same as [a-zA-Z0-9_])
\W Matches non-alphanumeric (same as [^a-zA-Z0-9_])
\s Matches whitespace
\S Matches non-whitespace)

Anchors

^ Matches the position at the beginning of the line
$ Matches the position at the end of the line
\b Matches the position between a \w\W or \W\w (word boundary)*
\B Matches the position between a \w\w or \W\W (non-word boundary)

* \b also matches at the beginning and end of a line

Quantifiers

? Match the previous element zero or one times (one if possible)
?? Match the previous element zero or one times (zero if possible)
+ Match the previous element one or more times (as many as possible)
+? Match the previous element one or more times (as few as possible)
* Match the previous element zero or more times (as many as possible)
e.g. The search pattern '1*' matches the '1' and the '11' strings in '1234543211+FIVEfiveF'.
The search pattern '.*' matches the entire string in '1234543211+FIVEfiveF'.
*? Match the previous element zero or more times (as few as possible)
{n} Match the previous element exactly n times
e.g. The search pattern '[0-9]{6}' matches the '123454' string in '123454321+FIVEfiveF'.
{n,} Match the previous element at least n times (as many as possible)
{n,}? Match the previous element at least n times (as few as possible)
{n,m} Match the previous element between n - m times (as many as possible)
{n,m}? Match the previous element between n - m times (as few as possible)

Unnamed Capture Groups

(...) Capture text matched between parentheses to an unnamed capture group. Unnamed capture groups (which are actually numbered captures) can be referenced in replace patterns.
e.g. The search pattern '([3-5])+FIVE(five)' matches '345+FIVEfive' in the string '123454321+FIVEfiveF'.
It also creates 2 groups. Group #1 matches the '345' and group #2 matches the 'five'.

Named Capture Groups

(?<foobar>...) Capture text matched between parentheses to a named capture group called “foobar”. Named capture groups can be referenced in replace patterns.

Lookaround

(?=...) Positive lookahead (match the position before the specified regex)
(?!...) Negative lookahead (don’t match, as above)
(?<=...) Positive lookbehind (match the position after the specified regex)
(?<!...) Negative lookbehind (don't match, as above)

Flags

(?x) Activate flag x

Replace pattern

Any text other than the variables below will be replaced as-is.

Capture Group References

\n Match the text in unnamed capture group #n, captured earlier in the search pattern
\<foobar> Match the text in named capture group “foobar”, captured earlier in the search pattern