Creating regular expressions

This topic provides general information about creating regular expressions. Click here for Examples of regular expressions when used with PATROL objects and pathnames.

Note

PATROL requires that you use certain conventions when specifying PATROL objects. For more information, see Creating regular expressions that specify PATROL objects or pathnames.

General conventions for using regular expressions

Character

Description

. (period)

matches any single character

(asterisk)

matches zero or more instances of the previous pattern item

+ (plus sign)

matches one or more instances of the previous pattern item

? (question mark)

matches zero or one instance of the previous pattern item

(\ ) (backslash and parenthesis)

groups a subpattern
The repetition and alternation operators apply to the whole proceeding subpattern.

| (backslash and vertical bar or pipe)

alternation

[ ] (brackets)

delimit a set of characters
Ranges are specified as [x-y]. If the first character in the set is ^, then there is a match if the remaining characters in the set are not present.

^ (caret)

anchors the pattern to the beginning of the string
When the caret is used in a regular expression, the search only returns matches where the pattern occurs at the beginning of the string. For example, ^ab matches ab in the string abcdef, but will not find a match in the string cdefab.

$ (dollar sign)

anchors the pattern to the end of the string
When the dollar sign is used in a regular expression, the search only returns matches where the pattern occurs at the end of the string.

\& (backslash and ampersand)

connects two or more regular expressions as an 'AND' operator.
Regular expressions are connected as (x ) \& (y , where 'x' and 'y' are valid regular expressions. The backslash and ampersand character is never used as a regular expression. It is always used and functions only as a connector between two or more regular expressions.

Was this page helpful? Yes No Submitting... Thank you

Comments