Regular Expression
Use this dialog box to specify the regular expression to exclude from (or apply to) backups.
A regular expression provides more specific filtering than the regular exclude filter. Regular expressions are applied globally to an entire set (not only specific items) to either exclude or include filenames and/or directories based on RegEx pattern(s).
NOTE: You should only use this option if you are familiar with the regular expression syntax.
Edit |
Expression | • Pre-defined: Select from one of the pre-defined expressions in the list. • Custom: Enter the regular expression string to exclude. |
Match Options • The default match options are to exclude the expression, with case sensitive filtering, against files and directories. |
Case Sensitive | [Default is selected.] Indicates if the expression matching is case sensitive. |
Negate | Negates the expression. This means it will exclude any files not matching the regular expression. This has the effect of permitting the negated expression to be backed up. • This option only works at the individual file level (not on directories). • For example, negating the pre-defined .*\.tmp expression allows you to exclude any files that do not have the .tmp extension. |
Inclusion | Inverts the regular expression to filter for the specified pattern. • If you add one inclusion to the list of items to be backed up, only files matching the inclusion will be backed up. No other files will backed up, unless additional inclusion expressions are added. • For example, selecting this option with the pre-defined .*\.tmp expression allows you to include all .tmp files from the shares and directories selected for backup. • Add multiple inclusion expressions to search for only the specified names or patterns. |
Match | Select what this regular expression will filter: • files and directories: Not available with the Negate option. • files only |
Test |
Match against | Checks the regular expression against a string you enter. Click the check icon to verify if the string matches the regular expression. |
A regular expression is a pattern that is matched against a subject string from left to right. Most characters stand for themselves in a pattern, and match the corresponding characters in the subject. The power of regular expressions comes from the ability to include alternatives and repetitions in the pattern. These are encoded in the pattern using meta-characters. There are two different sets of meta-characters: those that are recognized anywhere in the pattern except within square brackets, and those that are recognized in square brackets. Outside square brackets, the meta-characters are as follows:
\ | General escape character with several uses. |
^ | Assert start of string (or line, in multiline mode). |
$ | Assert end of string (or line, in multiline mode). |
. | Match any character except newline (by default). |
[ | Start character class definition. |
| | Start of alternative branch. |
( | Start subpattern. |
) | End subpattern. |
? | Extends the meaning of ( 0 or 1 quantifier Quantifier minimizer |
* | 0 or more quantifier |
+ | 1 or more quantifier Possessive quantifier |
{ | Start min/max quantifier. |
Part of a pattern that is in square brackets is called a “character class”. In a character class the only meta-characters are:
\ | General escape character. |
^ | Negate the class, but only if the first character. |
- | Indicates character range. |
[ | POSIX character class (only if followed by POSIX syntax). |
] | Terminates the character class. |
If you add multiple regular items to the set, and then add one or more negated RegEx exclusions that do not match the regular items, they are excluded. For example, if you add the following as regular items:
F:\Dir1
F:\Dir2
F:\Dir3
and then add a negated RegEx as:
~REGEX: (Exclusion, Case insensitive, Match files only) F: - \\Dir3\\.*\\ToBackup\\.*
This RegEx indicates to exclude everything that does not match F:\Dir3\.*\ToBackup\.*.
Since RegEx expressions are applied globally to the entire set, F:\Dir1 and F:\Dir2 will be excluded, as they do not match the regular expression. If someone wants to include F:\Dir1 and F:\Dir2, they have several options:
• Modify the negated RegEx to include Dir1 and Dir2 as follows:
~REGEX: (Exclusion, Case insensitive, Match files only) F: - \\(Dir1|Dir2|(Dir3\\.*\\ToBackup)\\.*
• Transform the negated RegEx to an inclusion. Then someone could either modify that inclusion to include the extra regular folders:
REGEX: (Inclusion, Case insensitive, Match files only) F: - \\(Dir1|Dir2|(Dir3\\.*\\ToBackup)\\.*
Or, add several RegEx inclusions:
REGEX: (Inclusion, Case insensitive, Match files only) F: - \\Dir1\\.*
REGEX: (Inclusion, Case insensitive, Match files only) F: - \\Dir2\\.*
REGEX: (Inclusion, Case insensitive, Match files only) F: - \\Dir3\\.*\\ToBackup\\.*
• Use one set for those regular items that do not need RegEx and another set for those that require RegEx.