Regular expressions

Article:HOWTO83154  |  Created: 2012-12-04  |  Updated: 2013-10-27  |  Article URL http://www.symantec.com/docs/HOWTO83154
Article Type
How To


Subject


Regular expressions

Table: Regular expressions lists examples of regular expressions that show how pattern matching is accomplished with the use of metacharacters and alphanumeric characters.

Table: Regular expressions

Regular expression

Description

abc

Matches any line of text that contains the three letters abc in that order.

Your results may differ depending on the comparison that you use to create the rule. For example, if you build a rule to match the word Free and use the Contains condition, then the filtering engine detects all words that contain the word Free instead of an exact match (for example, Freedom). However, if you use the Equal condition, then the filtering engine detects only exact matches of the word Free with no other surrounding text. If you use the Contains condition with Whole words only, then the filtering engine detects Free as a stand-alone word, even if there are other words present in the text that is being searched.

a.c

Matches any string that begins with the letter a, followed by any character, followed by the letter c.

^.$

Matches any line that contains exactly one character. (The newline character is not counted.)

a(b*|c*)d

Matches any string beginning with the letter a, followed by either zero or more instances of the letter b, or zero or more instances of the letter c, followed by the letter d.

.+\....\....

Matches any file name that has two, three-letter extensions (for example, Filename.gif.exe).

This regular expression is helpful in blocking email attachments with double extensions. For example:

If Attachment Name + .+\....\....

[0-9a-zA-Z]+<!--.*-->[0-0a-zA-Z]+

Matches an embedded comment in the middle of meaningful HTML text. Embedding comments within HTML text is a trick that spam senders use to bypass some pattern-matching software.

\s*

Matches a white space character zero or more times.

See About regular expressions

See About DOS wildcard style expressions


Legacy ID



v8925676_v82894070


Article URL http://www.symantec.com/docs/HOWTO83154


Terms of use for this information are found in Legal Notices