Real meaning of Regular Expression’s(RG’s)

It is a way of representing data using symbols, which are in the form of special characters like ‘*’,’ +’, ’.’,  ’’.

 Further these characters are used for search of particular pattern in strings.

RG’s in UFT:

These are used in UFT to identify objects and text strings with varying values very useful in dynamic objects.


1. Defining Properties of an Object. (Object Repository)

2. Pattern matching in Check points.

3. Parameterize an object property or check point

We can test pattern match using “Regular Expression Evaluator”

Tools>Regular Expression Evaluator.


Screenshot of window: RG evaluator

Using RG in UFT:

1. We can define a regular expression for a constant value, a Data Table parameter value, an Environment parameter value, or a property value in Descriptive programming.

2. We can define a regular expression in standard checkpoint to verify the property values of an object;we can set the expected value of an object’s property as a regular expression so that an object with a varying value can be verified.

3.We can define the text string as a regular expression, when creating a text checkpoint to check that a varying text string is displayed on our application,
4.For XML checkpoints we can set attribute or element values as regular expressions.

Types of RG’s:

i) Backslash Character:

 A backslash () can serve two purposes. It can be used in conjunction with a special character to indicate that the next character be treated as a literal character.

For example, UFT recognizes n as the special newline character. 

Alternatively, if the backslash () is used in conjunction with some characters that would otherwise be treated as literal characters, such as the letters n, t, w, or d, the combination indicates a special character. 

For example, w matches the character w
w is a special character that matches any word character including underscore.
Practical example:-
In the URL of a blog,
The period would be mistaken as an indication of a regular expression. To indicate that the

period is not part of a regular expression, you would enter it as follows:
uftautomation.blogspot .in

ii) Matching Any Single Character:

A period (.) tells UFT to search for any single character (except for n).
For example:

Matches Trains, Trained, or Train followed by a space or any other single character.
iii) Matching Any Single Character in a List:

Square brackets [] instruct UFT to search for any single character within a list of characters.
For example:
To search for the Year 2013, 2019, or 2015,
RG: 201[359] 
iv) Matching Any Single Character Not in a List:

 When a caret (^) is the first character inside square brackets, it instructs UFT
to match

 any character in the list except for the ones specified in the string.
For example:
RG: [^13]
Matches any character except 1 or 3.
v) Matching Any Single Character within a Range:

 To match a single character within a range, we can use square brackets ([ ]) with the 

hyphen () character.
For example: For matching any number in the range 1000s,

RG: 100[0-9] 

Screenshot: We are looking for 3 digit number between (130 -149)
RG: [1][3-4][0-9]
RG example for Range

vi) Matching Zero or More Specific Characters:

 An asterisk (*) instructs UFT to match zero or more occurrences of the preceding 


For example:
RG: ma*n 

Matches man, maaaaaan, and ma
vii) Matching One or More Specific Characters:

 A plus sign (+) instructs UFT to match one or more occurrences of the preceding 

For example:
RG: ma+n
Matches man and maaaaaaan, but not mn.

viii) Matching Zero or One Specific Character:

 question mark (?) instructs UFT to match zero or one occurrences of the preceding 

For example:
RG: ma?n
Matches man and ma , but nothing else.
ix) Grouping RG:

 Parentheses (()) instruct UFT to treat the contained sequence as a unit, just as in 

mathematics and programming languages. Using groups is especially useful for delimiting
 the argument(s) to an alternation operator ( | ) or a repetition operator ( * , + , ? , { } ).
x)  Matching One of Several RG’s:

 vertical line (|) instructs UFT to match one of a choice of expressions.
xi)  Matching the Beginning of a input:

 A caret (^) instructs UFT to match the expression only at the start of a line, or after

 a newline character.

xii)  Matches the end of input:

A dollar sign ($) instructs UFT to match the expression only at the end of a line, or before a newline character.

xiii)  Matching Any Alphanumeric Character Including the Underscore:

 w instructs UFT to match any alphanumeric character and the underscore any combination

 of (A-Z, a-z, 0-9, _).
xiv)  Matching Any Non-Alphanumeric Character:

 W instructs UFT to match any character other than alphanumeric characters and 

underscores any combination other than (A-Z, a-z, 0-9, _).

Some other cardinal RG’s:
a) Matches a digit character : d, it is  Equivalent to [0-9].
b) Matches a non-digit character: D, it is Equivalent to [^0-9].
c) Matches a newline character: n
d) Matches a carriage return character: r
e) Matches a tab character: t

4 replies on “Real meaning of Regular Expression’s(RG’s)”

Leave a Reply

Your email address will not be published. Required fields are marked *