27.11.2012 Views

IronPort - advanced configuration guide

IronPort - advanced configuration guide

IronPort - advanced configuration guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 6 Using Message Filters to Enforce Email Policies<br />

Regular Expressions in Rules<br />

OL-25137-01<br />

Several of the atomic tests used to define rules use regular expression matching. Regular expressions can<br />

become complex. Use the following table as a <strong>guide</strong> for the applying of regular expressions within<br />

message filter rules:<br />

Table 6-3 Regular Expression in Rules<br />

Regular expression (abc) Regular expressions in filter rules match a string if the sequence of<br />

directives in the regular expression match any part of the string.<br />

Carat (^)<br />

Dollar sign ($)<br />

Letters, white space and the at<br />

sign (@) character<br />

For example, the regular expression Georg matches the string George<br />

Of The Jungle, the string Georgy Porgy, the string La Meson<br />

Georgette as well as Georg.<br />

Rules containing the dollar sign character ($) only match the end of the<br />

string, and rules containing the caret symbol (^) only match the<br />

beginning of the string.<br />

For example, the regular expression ^Georg$ only matches the string<br />

Georg.<br />

Searching for an empty header would look like this: "^$"<br />

Rules containing characters, white space, and the at sign character (@)<br />

only match themselves explicitly.<br />

For example, the regular expression ^George@admin$ only matches the<br />

string George@admin.<br />

Period character (.) Rules containing a period character (.) match any character (except a<br />

new line).<br />

For example, the regular expression ^...admin$ matches the string<br />

macadmin as well as the string sunadmin but not win32admin.<br />

Asterisk (*) directive Rules containing an asterisk (*) match “zero or more matches of the<br />

previous directive.” In particular, the sequence of a period and an<br />

asterisk (.*) matches any sequence of characters (not containing a new<br />

line).<br />

For example, the regular expression ^P.*Piper$ matches all of these<br />

strings: PPiper, Peter Piper, P.Piper, and Penelope Penny Piper.<br />

Backslash special characters (\) The backslash character escapes special characters. Thus the sequence<br />

\. only matches a literal period, the sequence \$ only matches a literal<br />

dollar sign, and the sequence \^ only matches a literal caret symbol.<br />

For example, the regular expression ^ik\.ac\.uk$ only matches the<br />

string ik.ac.uk.<br />

Important Note: The backslash is also a special escape character for<br />

the parser. As a result, if you want to include backslash in your regular<br />

expression, you must use two backslashes — so that after parsing, only<br />

one “real” backslash remains, which is then passed to the regular<br />

expression system. So, if you wanted to match the example domain<br />

above, you would enter ^ik\\.ac\\.uk$.<br />

Cisco <strong>IronPort</strong> AsyncOS 7.6 for Email Advanced Configuration Guide<br />

6-15

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!