Regular expressions

Back
A regular expression uses metacharacters and wildcard characters to identify one or more characters that can be substituted in order to search for variations of the specified keyword or phrase.
Primarily for use within MailSweeper these metacharacters and wildcards can also be used with scripting languages that also use regular expressions.
You can use the following metacharacters and wildcard characters to create a regular expression.

Metacharacter Description
? Any single character.
* Zero or more of the preceding character or metacharacter.
+ One or more of the preceding character or metacharacter.
\ An escape sequence that specifies a metacharacter as a literal character. For example, \? indicates the question mark (?) is to be included in the search.
(abc) The group of characters "abc".
a|b One, but not both, of the characters.
(a|b|c) Any one of the characters.
[abc] Any one of the enclosed characters.
[a-c] Any one of the enclosed range of characters. This is equivalent to [c-a].
[0-9] Any one of the range of numbers.

You can include more than one metacharacter or wildcard in a regular expression. The second metacharacter or wildcard modifies the previous metacharacter or wildcard.
Regular expression examples

Regular Expression Searches for
.REGEXP. dog? The keyword dog plus any other single character. Thus, this would match "dogs".
.REGEXP. dog?+ The keyword dog or one or more of the preceding characters or wildcards. Thus, this would match "doggy".
.REGEXP. dog ?+ The keyword dog plus any other word. This would match, for example, "dog bowl", "dog food", "dog collar", and so on.
.REGEXP. ?*.doc Any characters immediately preceding the string .doc. This would match, for example, all filenames with a ".doc" file extension.
.REGEXP. \*.doc The string *.doc.
.REGEXP. ?+sweeper Any single character with one or more of the preceding characters or metacharacters followed by the string sweeper. This would match "MIMEsweeper", "MAILsweeper", "SECRETsweeper", and so on, but it would not match just the word "sweeper".
.REGEXP. ?*sweeper Any single character with zero or more of the preceding characters or metacharacters followed by the string sweeper. This would match the word "sweeper" as well as "MIMEsweeper", "MAILsweeper", "SECRETsweeper", and so on.
.REGEXP. gr[ae]y The characters gr followed by either the character a or the character e followed by the character y. This would match the word "gray" or the word "grey".
.REGEXP. (color)|(colour) The string color, or the string colour, but not both.
save .NEAR. .REGEXP. ?*pounds .OR. time .ANDNOT. the files The keyword save within the specified proximity of either the keyword pounds itself (or a word ending with the characters pounds) or the keyword time, but not the expression the files.
Alternatively, use parentheses to make the expression easier to read:
save .NEAR. (.REGEXP. ?*pounds .OR. time) .ANDNOT. the files Thus, this expression would match the phrase "save time" but not the phrase "save the files".

Back