About Regular Expressions

Home  Previous  Next

Regular expressions are used in Monitoring Studio to define strings to be searched for. A regular expression is:

A string formatted with a specific syntax.
It is intended to select some lines in a text, which will match the regular expression.

Regular expressions are commonly used in pattern matching, and especially on UNIX systems with the grep, awk and sed commands. You can use regular expressions in Monitoring Studio in order to:

Find a process
Search for strings in a file
Check a web page
Parse a table in a database

The following table describes the regular expression syntax that is supported in Monitoring Studio.

Character

Meaning

. (dot)

Match any single character

Example:
Err.. will match Err01, Err02 or ErrAB, etc.

[xyz]

Match any character in the brackets

Example:
Err[123] will match Err1, Err2 or Err3
[Ee]rror will match either error or Error

[^xyz]

Match any character not in the brackets

Example:
Err[^12345] will match Err0, Err6, Err7, etc. but not Err1

[a-z]

Match any character in the range in the brackets

Example:
Err[0-9] will match Err0, Err1, etc. and Err9
Err[A-Z][0-9] will match ErrA0, ErrA1, ErrS9, ErrZ0, etc. but not Err1A
Err[A-Z0-9] will match ErrA0, ErrA1, etc. and Err1A

[^a-z]

Match any character not in the range in the brackets

Example:
Application[^0-9] will match ApplicationA, ApplicationB, Application! but not Application1

*

Match zero or more repetitions of the preceding

Example:
Err[0-9A-F]* will match Err, Err0, ErrA, Err11, ErrBF0001, etc.
Error.*ApplicationABC will match all lines that contains Error and ApplicationABC further (Critical Error 0x000295F0 on ApplicationABC)

+

Match one or more repetitions of the preceding

Example:
Err[0-9A-F]+ will match Err0, ErrA, Err11, ErrBF0001, etc. but not Err

^

Match the beginning of the line

Example:
^Err will match all lines that begin with Err

$

Match the end of the line

Example:
[0-9]+ connections$ will match all lines that end with xxx connections where xxx is an integer

\<

Match the beginning of a word

Example:
\<set will match any line that contains a word that begins with set. It will not match a line that only contains the word unset

\>

Match the end of a word

Example:
[Aa]pplication\> will match all lines that contain the word Application or application but not ApplicationAA

\(expression\)

Defines an expression which has to be processed as a unit regarding the modifier *, + and \|

Example:
\(_[a-zA-Z0-9]\)+ will match only sequences like _patrol, _patrol_agent, _patrol_console, etc.

exprA\|exprB

Match either exprA or exprB

Example:
\(firewall\)\|\(antivirus\) will match all lines that contains either the word firewall or the word antivirus

\

Avoid the meaning of the following character

Example:
\. will match the single character dot (.)
C:\\Program Files will match C:\Program Files