Regular Expression Syntax - WinRunner

Regular expressions must begin with an exclamation point (!), except when defined in a Check GUI dialog box, a text checkpoint, or a match, obj_find_text, or win_find_text statement. All characters in a regular expression are searched for literally, except for a period (.), asterisk (*), caret (^), and brackets ([ ]), as described below. When one of these special characters is preceded by a backslash (), WinRunner searches for the literal character. For example, if you are using a win_find_text statement to search for a phrase beginning with “Sign up now!”, then you should use the following regular expression: “Sign up now!*.”.

The following options can be used to create regular expressions:

Matching Any Single Character

A period (.) instructs WinRunner to search for any single character. For example,


matches welcomes, welcomed, or welcome followed by a space or any other single character. A series of periods indicates a range of unspecified characters.

Matching Any Single Character within a Range

In order to match a single character within a range, you can use brackets ([ ]). For example, to search for a date that is either 1968 or 1969, write:


You can use a hyphen (-) to indicate an actual range. For instance, to match any year in the 1960s, write:


Brackets can be used in a physical description to specify the label of a static text object that may vary:

class: static_text,
label: "!Quantity[0-9]"

In the above example, WinRunner can identify the static_text object with the label “Quantity” when the quantity number varies.

A hyphen does not signify a range if it appears as the first or last character within brackets, or after a caret (^).

A caret (^) instructs WinRunner to match any character except for the ones specified in the string. For example:


matches any non-alphabetic character. The caret has this special meaning only when it appears first within the brackets.

Note that within brackets, the characters “.”, “*”, “[“ and “” are literal. If the right bracket is the first character in the range, it is also literal. For example:


matches the “]“ and g through m.

Matching Specific Characters

An asterisk (*) instructs WinRunner to match one or more occurrences of the preceding character. For example:


causes WinRunner to match Q, QQ, QQQ, etc.

A period “.” followed by an asterisk “*” instructs WinRunner to locate the preceding characters followed by any combination of characters. For example, in the following physical description, the regular expression enables WinRunner to locate any push button that starts with “O” (for example, On or Off):

class: push_button
label: "!O.*"

You can also use a combination of brackets and an asterisk to limit the label to a combination of non-numeric characters. For example:

class: push_button
label: "!O[a-zA-Z]*"

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd Protection Status

WinRunner Topics