Regular Expression filter
Previous  Top  Next


Overview
Allows the use of Unix type regular expression matching. Useful for matching ranges of numbers, letters or symbols in the text. Allows maximum control over what is searched for within the text, including specifying the location within the text to match.


Allows for AND, OR, NOT OR, NOT AND, and exclusion matching.


Details
The regular expression filter allows you to specify Unix type regular expression arguments to tightly control what and where text is matched.


Each search string must be contained by double quotes. Multiple quoted search strings can be placed next to each other on the same line. The filter will then match any of the strings specified. This is an implicit OR relationship.

The [C] button selects a case sensitive or case in-sensitive string search.

The filter matching process will ignore any blank fields.

Leaving the first two fields blank and specifying text in the third and or fourth fields can perform exclusion matching. In this case, if the text is NOT matched the result will be true.


Example:


reg exp example1

All strings must be contained in double quotes. Items can be listed next to each other and will be OR'd together.

The filter above reads as:

If the message text starts with "The" (case sensitive) and ends with "dog" but does not contain "chicken" and "Duck" then the result will be true.

reg exp example2

This is an example of an exclusion filter:

If the message text does NOT contain the word "The" at the start and the word "dog" at the end then the result will be true.
Notice the first two fields are left blank. These fields will be ignored during the filter processing.

Notes:

The "And:" fields can be left blank if they are not required.

If the "And:" fields contain values, the field above it must also contain data.


Regular Expression Syntax:

Special characters and sequences are used in writing patterns for regular expressions. The following table describes and gives an example of the characters and sequences that can be used:

Char   Description

^
   Beginning of a string.

$
   End of a string.

.
   Any character.

?
   Repeat previous character zero or one time. For example, "10?" matches "1" and "10".

*
   Repeat previous character zero or more times. For example, "10*" matches "1", "10", "1000", etc.

+
   Repeat previous character one or more times. For example, "10+" matches "10", "1000", etc.

\
   Escape next character. This is required to any of the special characters that are part of the syntax. For example "\.\*\+\\" matches ".*+\". It is also required to encode some special non-printable characters (such as tabs) listed below.

x|y   Matches either x or y. For example, "z|wood" matches "z" or "wood". "(z|w)oo" matches "zoo" or "wood". 

{n}   n is a nonnegative integer. Matches exactly n times. For example, "o{2}" does not match the "o" in "Bob," but matches the first two o's in "foooood".

{n,}    n is a nonnegative integer. Matches at least n times. For example, "o{2,}" does not match the "o" in "Bob" and matches all the o's in "foooood." "o{1,}" is equivalent to "o+". "o{0,}" is equivalent to "o*".

n , m }    m and n are nonnegative integers. Matches at least n and at most m times. For example, "o{1,3}" matches the first three o's in "fooooood." "o{0,1}" is equivalent to "o?".

xyz ]    A character set. Matches any one of the enclosed characters. For example, "[abc]" matches the "a" in "plain". 

[^ xyz ]    A negative character set. Matches any character not enclosed. For example, "[^abc]" matches the "p" in "plain". 

a-z ]    A range of characters. Matches any character in the specified range. For example, "[a-z]" matches any lowercase alphabetic character in the range "a" through "z". 

[^ m-z ]    A negative range characters. Matches any character not in the specified range. For example, "[m-z]" matches any character not in the range "m" through "z". 

\b   Matches a word boundary, that is, the position between a word and a space. For example, "er\b" matches the "er" in "never" but not the "er" in "verb". 

\B   Matches a non-word boundary. "ea*r\B" matches the "ear" in "never early". 

\d   Matches a digit character. Equivalent to [0-9]. 

\D    Matches a non-digit character. Equivalent to [^0-9]. 

\f    Matches a form-feed character. 

\n    Matches a newline character. 

\q   Quote character or ASCII value of 34 

\r    Matches a carriage return character. 

\s    Matches any white space including space, tab, form-feed, etc. Equivalent to "[ \f\n\r\t\v]".

\S    Matches any nonwhite space character. Equivalent to "[^ \f\n\r\t\v]". 

\t    Matches a tab character. 

\v    Matches a vertical tab character. 

\w    Matches any word character including underscore. Equivalent to "[A-Za-z0-9_]". 

\W    Matches any non-word character. Equivalent to "[^A-Za-z0-9_]". 

\num    Matches num, where num is a positive integer. A reference back to remembered matches. For example, "(.)\1" matches two consecutive identical characters. 

n    Matches n, where n is an octal escape value. Octal escape values must be 1, 2, or 3 digits long. For example, "\11" and "\011" both match a tab character. "\0011" is the equivalent of "\001" & "1". Octal escape values must not exceed 256. If they do, only the first two digits comprise the expression. Allows ASCII codes to be used in regular expressions.

\xn   Matches n, where n is a hexadecimal escape value. Hexadecimal escape values must be exactly two digits long. For example, "\x41" matches "A". "\x041" is equivalent to "\x04" & "1". Allows ASCII codes to be used in regular expressions.


For example:

"^stuff"                    ' any string starting with "stuff"
"stuff$"                    ' any string ending with "stuff"
"o.d"                       ' "old", "odd", "ord", etc
"o[ld]d"                    ' "old" or "odd" only
"o[^l]d"                    ' "odd", "ord", but not "old"
"od?"                       ' "o" or "od"
"od*"                       ' "o", "od", "odd"
"od+"                       ' "od", "odd", etc
"\."                        ' decimal point (needs escape character)
"[A-Z][a-z]*"               ' any uppercase word
"[0-9]+"                    ' any stream of digits
"[1-9]+[1-9]*"              ' any stream of digits not starting with zero
"[+\-]?[0-9]*[\.]?[0-9]*"   ' any number with optional sign and decimal point
                            '(needs two escape characters)
"dst=\qLOCAL MACHINE\q"      ' finds occurrence of "dst="LOCAL MACHINE"" 
"dst=\x22LOCAL MACHINE\x22"   ' finds occurrence of "dst="LOCAL MACHINE""; Hex(22) = ASCII 34, or (")
"(z|w)oo"         ' finds occurances of "zoo" or "woo"