Previous Topic: Configure Text Pattern ExclusionNext Topic: SNMPv3 Configuration


Regular Expression Examples

This section provides examples for using the watch logfile directive in the sysedge.cf file to add regular expression to the Log Monitor table.

Simple Expression

Example: /the quick brown fox/

The following example searches for the regular expression '/the quick brown fox/' in the sentences:

Input
The quick brown fox jumps over the lazy dog.
the quick brown fox jumps over the lazy dog.
Result
the quick brown fox

Case-Insensitive Expression

Example: /The quick brown fox/i

The following example searches for the regular expression '/The quick brown fox/i' in the sentences. The search matches for the expression 'The quick brown fox', regardless of the case.

Input
The quick brown fox jumps over the lazy dog.
the quick brown fox jumps over the lazy dog.
the quick brown FOX jumps over the lazy dog.
Result
The quick brown fox jumps over the lazy dog.
the quick brown fox jumps over the lazy dog.
the quick brown FOX jumps over the lazy dog.

Multiline Mode - Start of Line and End of Line Metacharacters

Example: /^abc$/m

The following example searches for the regular expression '/^abc$/m' in the sentences. This expression matches only if the pattern 'abc' is on its own line.

Input
Lazy dog\nquick horse\nabc
Result
abc

Multiline Mode - PCRE_DOTALL

Example: /two.*three.*four/s

The following example searches for the regular expression '/two.*three.*four/s' in the sentences. When the PCRE_DOTALL pattern modifier is specified, the dot metacharacter also matches on newlines.

Input
one number\ntwo numbers\nthree numbers\nfour numbers\nfive numbers
Result
Two numbers\nthree numbers\nfour

Extended Expression - Ignoring Whitespace

Example: /^1234 # comment in input string/x

The following example searches for the regular expression '/^1234 #comment in extended re/x' in the sentences. This expression matches on the quoted text, regardless of whitespace encountered in the input.

Input
1234 #comment in input string
1234 #	comment 	in	input   string
1234#commentininputstring
Result
1234 #comment in input string
1234 #	comment 	in	input   string
1234#commentininputstring

Dollar Sign Matches Only at End

Example: /X$/E

The following example searches for the regular expression '/X$/E' in the sentences. The text in the pattern (“X”) matches only at the end of the subject string.

Input
Test X
What can I do with X		
Result
X
X

JavaScript Compatible

Example: /a[^]b/<JS>

The following example searches for the regular expression '/a[^]b/<JS>' in the sentences. Specifying the “<JS>” pattern modifier activates JavaScript compatibility mode for this expression.

Input
aXb
Result
aXb