Further these characters are used for search of particular pattern in strings.
2. Pattern matching in Check points.
3. Parameterize an object property or check point
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.
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.
w is a special character that matches any word character including underscore.
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.
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,
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.
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]
An asterisk (*) instructs UFT to match zero or more occurrences of the preceding
character.
Matches man, maaaaaan, and ma
A plus sign (+) instructs UFT to match one or more occurrences of the preceding
character.
For example:
RG: ma+n
Matches man and maaaaaaan, but not mn.
A question mark (?) instructs UFT to match zero or one occurrences of the preceding
character.
For example:
RG: ma?n
Matches man and ma , but nothing else.
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 ( * , + , ? , { } ).
A vertical line (|) instructs UFT to match one of a choice of expressions.
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.
w instructs UFT to match any alphanumeric character and the underscore any combination
of (A-Z, a-z, 0-9, _).
W instructs UFT to match any character other than alphanumeric characters and
underscores any combination other than (A-Z, a-z, 0-9, _).
e) Matches a tab character: t
4 replies on “Real meaning of Regular Expression’s(RG’s)”
Looks like a complete tutorial. Awesome
Jagmeet
http://jagsntwitter.blogspot.in/
Best Qtp blog.. the examples are very clear and apt.
Keep posting!
Very nice explanation Mandeep.
It will be very helpful for the QA guys.
Gud luck:)
Really enjoyed learning this . Thanks!!