Regular expression syntax
For more information on regular expression syntax, see Open Group Base Specifications Issue 6, Chapter 9 here: http://pubs.opengroup.org/onlinepubs/007904875/basedefs/xbd_chap09.html. If you want to test the match results for your expression before using it in your workflow, you can find many free utilities on the Web. For example, this is a free browser-based expression testing tool: http://gskinner.com/RegExr/.
Syntax summary
- Period (.) matches a single occurrence of any character (letter or number).
- Asterisk (*) matches zero or more occurrences of the preceding character, up to the maximum file name length.
- Backslash (\) is the escape character that means that the next character is interpreted literally.
- Dollar sign ($) means that a match signifies the end of the expression.
- Question mark (?) makes the preceding token optional; for example, colou?r would match color or colour.
- Plus sign (+) matches one or more of the preceding token.
Characters in the value are case-sensitive. For example, .*PDF$,.*AFP$ represent patterns that are different from .*pdf$,.*afp$.
Separate multiple patterns by commas; do not type a space between them.
Note that although you commonly see *. used as a matching term (for example, when searching for files on a Windows system), this sequence of characters is not valid regular expression syntax.
This is an example of a regular expression that uses the first four alphanumeric characters of the file name:
[A-Za-z0-9]{4}
The pattern in square brackets, [A-Za-z0-9], matches any characters in the ranges A–Z, a–z, or 0–9. The number in braces, {4}, indicates the number of characters to use.