WelcomeProducts & ServicesSecurity ResponseSupportSolutions & IndustriesLicensingTraining
Enterprise
Symantec.com > Enterprise > Support > Knowledge Base

Regular expressions you can use to set up spam rules in Symantec Mail Security for Microsoft Exchange

Question/Issue:
You want to create content filtering rules by using regular expressions to set up spam rules for Symantec Mail Security 4.x or 5.x for Microsoft Exchange.


Solution:
Creating rules under the Filter Policy allows the administrator to filter on subject, sender, or message body for the Symantec Exchange product. You can use a set of UNIX-based regular expressions (characters and symbols) to create rules. When creating a rule, you can use UNIX-based Regular expressions to flag variations of a subject line or sender. UNIX-based Regular expressions only work for the Spam Rule.

Some DOS-based regular expressions, as noted in the following table, will not work for the Spam Rule. Only the UNIX-based regular expressions will work. The independent Subject Line rule (not the spam rules created for the subject field) is capable of using the DOS-based regular expressions only.


Notes:

Regular expressions
The spam lists can handle robust regular expressions. The entries for the Spam List settings (subject list and sender list) use UNIX-style regular expressions. These differ from DOS-style wildcard matching. Using the following regular expressions, you can match:
For example, the regular expression string .*spam.? matches spam, bigspam, spam7, and bigspam7.

The following table lists the symbol, name, platform, a brief description, and an example of the regular expression:

SymbolNamePlatformDescriptionExample
^Must start with.UNIX
only
The line must start with what follows: ^^free matches any string with "free" as the first word. For example: Free money today!
$Must end with.UNIX
only
The line must end with what precedes: $today$ matches any string ending with the word "today." For example: Buy it today
.Match all characters for the given position.UNIX
only
Match any character where the period is located.l..k matches "link", "look", "lank", "lark", "lo k", "l k", "l33k", etc., but not "latchbock".
?0 or 1 instance of a character.UNIXMatches 0 or 1 instance of the character to the immediate left of the question mark.lo?k matches "lok" or "lk", but not "lock", "look" or "loooook".
?Match all characters at this positionDOSMatch all characters only at the current position.lo?k matches "look", "lock", "lork", "lo1k", etc., but not "lok".
*0 or more instances of a character.UNIXMatches 0 or more instances of the character to the immediate left of the asterisk.a*k matches "k", "ak", "aaaak", "aaaaaaaaaaaaaaaak", etc., but not "ack" or "ik."

Note: To enter a "catch-all" similar to the DOS equivalent of "*," you would need to enter ".* ", to match 0 or more instances of any character.
*Match all.DOSMatch all characters for any length.*k matches "k", "lock", "pack", "network", "overwork", etc.
+1 or more instances of a character.UNIX
only
Matches 1 or more instances of the character to the immediate left of the plus sign.b+e matches "be", "bbe", "bbbbbbbbe", etc., but would not match "brie" "bee", or "e".
[ ]Match only the characters listed within the brackets.UNIX
only
Match only with the characters listed the brackets. All the symbols with in the brackets are implicitly escaped for you. Except for the "^". (Case Sensitive)[bhmy]e matches "be", "he", "me", "ye", "mye", "bye", "hbmye", etc., but not "humble" or "e".
[^]Match all characters except the ones listed within the brackets.UNIX
only
Match all character except those listed within the brackets. All the symbols with in the brackets are implicitly escaped for you. Except for the "^". (Case Sensitive)be[^s]t matches "belt", "beat", "bert", "beAt", "be4t", "beSt", but not "best".
( )Override PrecedenceUNIX
only
Used to override the precedence of the regular expression symbols((\$.*!)|(!.*\$)) Would enable three separate statements to be taken into account before completing the equation applied to a string.

(\$.*!) - ".*" Anything and everything between a "\$" dollar sign and an "!" exclamation point.

(!.*\$) -  ".*" Anything and everything between an "!" exclamation point and a "\$" dollar sign.

(...|...) - Either section 1 "|" or section 2

So, "$Free money today!" and "!Unbelievable offer$" would be caught, but not "Important message!" or "Time to think about the $."
|ORUNIX
only
Either the expression to the left of the pipe or to the right of the pipe must match to make the whole expression true.this|that matches any string containing the words "this" or "that."
\EscapeUNIX
only
Placed in front of the symbol so the literal is used and not the expression meaning. (i.e. \$ means use the $ , not match everything preceding the $)free\$ matches "free$" anywhere in the string, but does not require "free" to be the last word in the string.
\s space UNIXPlaced in the expression when a space is needed.The text "RE\s\[ " in an expression will block RE [ with an escape sequence before "["



Note: Regular expressions are the default when using the "Text value" field, but that there is an option to use Regular Expressions, DOS wildcards, or literal strings when configuring a Match List.

Expression precedence
When using regular expressions in a spam rule, the precedence order of the regular expression symbols is from highest precedence to lowest. The following list is in order of precedence, from highest to lowest:
( ) Precedence override
| OR
[ ] List
\ Escape
^ Start with
$ End with
. Match position
? Zero or one instance
* Zero or more instances
+ One or more instances


Examples of combined regular expressions
The following are just a few examples of the power of regular expressions:

Note: Symantec strongly recommends testing in a nonproduction environment or setting the spam rule to log only to avoid blocking or deleting valid email.


Spam list issues and limitations
The spam list implementation has several issues and limitations:

 

Available Translations:


RATE THIS SOLUTION
Was this solution helpful to you?
Yes
No
If any information was unclear, or the information you were seeking was not provided, please let us know. Your feedback will help us improve this service.

NOTE: Comments entered here will NOT recieve a personal email response.


Document ID: 2003101710425654
Last Modified: 11/14/2007
Date Created: 10/17/2003
Operating System(s): Windows 2000 Server, Windows 2000 Advanced Server, Windows 2000 Datacenter Server, Exchange 2000 Standard Edition, Exchange 2000 Enterprise Edition, Windows Server 2003 Standard Edition, Windows Server 2003 Enterprise Edition, Windows Server 2003 Datacenter Edition, Exchange 2003 Standard Edition, Exchange 2003 Enterprise Edition
Product(s): Symantec Mail Security 4.0 for Microsoft Exchange, Symantec Mail Security 4.5 for Microsoft Exchange, Symantec Mail Security 4.6 for Microsoft Exchange, Symantec Mail Security 5.x for Microsoft Exchange
Release(s): 5.0 [All Releases], MSME 5.0 [All Releases], SMS 4.5 [All Releases], SMS 4.6 [All Releases], SMSME 4.0 [All Releases]



Site Index · Legal Notices · Privacy Policy · Contact Us · Global Sites
©1995 - 2009 Symantec Corporation