A regular expression pattern is a series of characters that are matched against incoming character strings called as operators. You can use these patterns when you define expression criteria as regex. Additonally, regular expression patterns can be used to customize the log view filter.
Reserved Characters
Following characters are reserved as operators:
. ? + * | { } [ ] ( ) # @ & < > ~ " \
To use one of these characters, escape it with a preceding backslash or surround it with double quotes. For example:
Operator | Example |
---|---|
\@ | # renders as a literal '@' |
\\ | # renders as a literal '\' |
"[email protected]" | # renders as '[email protected]' |
Standard Operators
A standard operator consists of one or more reserved characters separated by ampersand (&) or tilde (~) characters. A standard operator is matched by attempting to match each of its component reserved characters against the entire input string.
Operator | Description |
---|---|
. | Matches any character. For example: ab. # matches 'aba', 'abb', 'abz', and so on. |
+ | Repeat the preceding character one or more times. For example: ab+ # matches 'ab', 'abb', 'abbb', and so on. |
? | Repeat the preceding character zero or one time. Often used to make the preceding character optional. For example: abc? # matches 'ab' and 'abc' |
* | Repeat the preceding character zero or more times. For example: ab* # matches 'a', 'ab', 'abb', 'abbb', and so on. |
{} | Minimum and maximum number of times the preceding character can repeat. For example: a{2} # matches 'aa' a{2,4} # matches 'aa', 'aaa', and 'aaaa' a{2,} # matches 'a` repeated two or more times |
| | OR operator. The match succeeds if the longest pattern on either the left side OR the right side matches. For example: abc|xyz # matches 'abc' and 'xyz' |
( … ) | Forms a group. You can use a group to treat part of the expression as a single character. For example: abc(def)? # matches 'abc' and 'abcdef' but not 'abcd'. |
[ … ] | Match one of the characters in the brackets. For example: [abc] # matches 'a', 'b', 'c' Inside the brackets, - indicates a range unless - is the first character or escaped. For example: [a-c] # matches 'a', 'b', or 'c' [-abc] # '-' is the first character. Matches '-', 'a', 'b', or 'c' [abc\-] # Escapes '-'. Matches 'a', 'b', 'c', or '-' A ^ before a character in the brackets negates the character or range. For example: [^abc] # matches any character except 'a', 'b', or 'c' [^a-c] # matches any character except 'a', 'b', or 'c' [^-abc] # matches any character except '-', 'a', 'b', or 'c' [^abc\-] # matches any character except 'a', 'b', 'c', or '-' |
~ | You can use ~ to negate the shortest following pattern. For example: a~bc # matches 'adc' and 'aec' but not 'abc'. ~(abc.+) matches everything except terms beginning with 'abc'. |
<> | You can use foo<1-100> # matches 'foo1', 'foo2' ... 'foo99', 'foo100' foo<01-100> # matches 'foo01', 'foo02' ... 'foo99', 'foo100'. <10-100> matches all values between 10 and 100 |
& | Enables the aaa.+&.+bbb # matches 'aaabbb'. |
@ | Enables the @ operator. You can use @ to match any entire string. You can combine the @ operator with & and ~ operators to create an "everything except" the logic. For example: @&~(abc.+) # matches everything except terms beginning with 'abc'. |
Pattern Examples
Patterns | Example |
---|---|
.* | Matches an arbitrary string of characters. For example: server.*\.example\.com matches server-ny.example.com and server.example.com. |
.? | Matches any single character. For example: server.?\.example\.com matches server3.example.com and serverB.example.com, but not server10.example.com. |
(.+) | Matches non empty values. |
~(.+) | Matches only empty values. |