Where to Use Regular Expressions

Regular Expressions may be used in file masks, address masks, Modem Responses and File-Boxes configuration, i.e. anywhere where generic masks are allowed (though Modem Responses do not allow generic masks)

Argus uses Perl-Compatible Regular Expressions library (c) 1997-1999 University of Cambridge. This library was written by Philip Hazel <ph10@cam.ac.uk>, University Computing Service, New Museums Site, Cambridge CB2 3QG, England, Phone: +44 1223 334714.

Information about Perl-Compatible Regular Expressions (PCRE) syntax is given in a separate chapter, written by Philip Hazel.

Syntax

To insert a Regular Expression, use '~' character as a marker. Next character (following '~' marker) will be used as a delimiter to define the end of a Regular Expression. Any text found between delimiting characters will be treated as a Regular Expression.

The syntax is:

before~#regularexpression#after

where "before" and "after" is optional text that will be compared as a generic mask (a character matches itself, '?' matches any character, '*' matches a sequence of characters).

"regularexpression" is a text of a Regular Expression.

'#' - delimiter character.

Examples

The following string (found where a file mask should be)

~#cat(aract|erpillar|)\..*#

will match a file named "cat", "cataract", or "caterpillar", with any extension.

the above example is equivalent to

~#cat(aract|erpillar|)#.*

because the text after delimiter (".*") is treated as a generic mask, i.e. '.' matches a dot character and '*' matches any sequence of characters.

Here is another example of using regular expressions in Modem Responses:

~#^RING(\x20\d)?$#

This will match word "RING", optionally following a digit after space character.

List Separators and Regular Expression Delimiters

Because of space (or other) character may be used as a separator in Argus Configuration String Grids, such character should not occur in non-escaped form inside a regular expression. This is because of separator characters in a string grid (e.g. space) have greater priority than a regular expression delimiters (e.g. '#').

To avoid using string grid separator character in a Regular Expression, use hex codes (e.g. \x20 for space character) or corresponding patterns (e.g. \s , that will match any whitespace character).

If you plan using '#' character within a regular expression, you may also use it's hex code, but better way would be choosing another delimiter.

~`^RING(\x20#\d)?$`

To insert ~ character into a generic mask, double it to avoid using it as a regular expression marker.

Anchoring in File Masks

Note that you don't need to anchor your regular expressions (using '^' and '$') in file masks - they would be anchored automatically. If you need to skip some characters before of after, use ".*")

PCRE Default Options

The settings of PCRE_CASELESS, PCRE_MULTILINE, PCRE_DOTALL, and PCRE_EXTENDED options (described in separate chapter) can be changed from within the pattern by a sequence of Perl option letters enclosed between "(?" and ")", although the following default options are used:

When matching file names and path names - PCRE_CASELESS.

When matching modem responses - PCRE_MULTILINE, because the regular expression is matching against the entire multi-line input data stream coming from a modem.

In all other cases none of PCRE options are set by default.