Regular Expression syntax

This table lists the meta-characters understood by the WhatsUp Gold Regex Engine.

Matching a Single Character

Meta-character

Matches

 .

dot

Matches any one character

 [...]

character class

Matches any character inside the brackets.
Example, [abc] matches "a", "b", and "c"

 [^...]

negated character class

Matches any character except those inside the brackets.
Example, [^abc] matches all characters except "a", "b", and "c".
See below for alternate use - the way ^ is used controls its meaning.

 -

dash

Used within a character class. Indicates a range of characters.
Example: [2-7] matches any of the digits "2" through "7".
Example: [0-3a-d] is equivalent to [0123abcd]

 \

escaped character

Interpret the next character literally. 
Example: 3\.14 matches only "3.14". whereas 3.14 matches "3234", etc.

 \xnn

binary character

Match a single binary character. nn is a hexadecimal value between 00 and FF.
Example: \x41 matches "A"
Example: \x0B matches Vertical Tab

Quantifiers

Meta-character

Matches

 ?

question

One optional. The preceding expression once or not at all.
Example: colou?r matches "colour" or "color"
Example: [0-3][0-5]? matches "2" and "25"

 *

star

Any number allowed, but are optional.
Example:  .*  Zero or more occurrences of any character

 +

plus

One required, additional are optional.
Example, [0-9]+ matches "1", "15", "220", and so on

??, +?, *?

 

"Non-greedy" versions of ?, +, and *. Match as little as possible, whereas the "greedy" versions match as much as possible
Example: For input string <html>content</html>
<.*?> matches <html>
<.*> matches <html>content</html>

Matching Position

Meta-character

Matches

 ^

caret

Matches the position at the start of the input.
Example: ^2 will only match input that begins with "2".
Example: ^[45] will only match input that begins with "4" or "5"

 $

dollar

At the end of a regular expression, this character matches the end of the input.
Example: >$ matches a ">" at the end of the input.

Other

Meta-character

Matches

 |

alternation

Matches either expression it separates.
Example:  H|Cat matches either "Hat" or "Cat"

 (...)

parentheses

Provides grouping for quantifiers, limits scope of alternation via precedence.
Example: (abc)*  matches 0 or more occurrences of the the string abc
Example: WhatsUp (Gold)|(Professional) matches "WhatsUp Gold" or "WhatsUp Professional"

 \0, \1, ...

backreference

Matches text previously matched within first, second, etc, match group (starting at 0).
Example: <{head}>.*?</\0> matches "<head>xxx</head>".

!

negation

The expression following ! does not match the input
Example: a!b matches "a" not followed by "b".

Abbreviations

Abbreviations are shorthand Meta-characters.

Abbreviation

Matches

\a

Any alphanumeric character: ([a-zA-Z0-9])

\b

White space (blank): ([ \\t])

\c

Any alphabetic character: ([a-zA-Z])

\d

Any decimal digit: [0-9]

\D

Any non decimal digit [^0-9]

\h

Any hexadecimal digit: ([0-9a-fA-F])

\n

Newline: (\r|(\r?\n))

\p

Any punctuation character:  ,./\';:"!?@#$%^&*()[]{}- _=+|<>!~

\P

Any non-punctuation character

\q

A quoted string: (\"[^\"]*\")|(\'[^\']*\')

\s

WhatsUp Gold style white space character [ \\t\\n\\r\\f\\v]

\S

WhatsUp Gold style non-white space character [^ \\t\\n\\r\\f\\v]

\w

Part-of-word character ([a-zA-Z0-9_])

\W

Non-word character ([^a-zA-Z0-9_])

\z

An integer: ([0-9]+)

Related Topics

Script Syntax

Script Syntax: Expect=Keyword

Script Syntax: Flow Control Keywords

Script Syntax: Send=Keyword

Script Syntax: SimpleExpect Keyword