a) Backslash Character:
1. A backslash (\) used in conjunction with a special character to indicate that the next character be treated as a literal character.
2.also such as the letters \n, \t, \w, or \d, the combination indicates a special character.
b) Matching Any Single Character:
A period (.)(except for \n).
Ex:
welcome.
Matches welcomes, welcomed, or welcome
c) Matching Any Single Character in a List:
To search for the date 1867, 1868, or 1869, enter:
186[789]
d) Matching Any Single Character Not in a List:
[^ab]
Matches any character except a or b.
e) Matching Any Single Character within a Range:
For matching any year in the 2010s, enter:
201[0-9]
f) Matching Zero or More Specific Characters:
ca*r
Matches car, caaaaaar, and cr
g) Matching One or More Specific Characters:
A plus sign (+) instructs QTP to match one or more occurrences of the preceding character.
For example:
ca+r
Matches car and caaaaaar, but not cr.
h) Matching Zero or One Specific Character:
(?) instructs QTP to match zero or one occurrences of the preceding character.
For example:
ca?r
Matches car and cr, but nothing else.
i) Grouping Regular Expressions:
Parentheses (()) instruct QTP 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 ( * , + , ? , { } ).
j) Matching One of Several Regular Expressions:
pipe (|) instructs QTP to match one of a choice of expressions.
k) Matching the Beginning of a Line:
A caret (^) instructs QTP to match the expression only at the start of a line, or after a newline character.
l) Matching the End of a Line:
A dollar sign ($) instructs QTP to match the expression only at the end of a line, or before a newline character.
m) Matching Any AlphaNumeric Character Including the Underscore:
\w instructs QTP to match any alphanumeric character and the underscore (A-Z, a-z, 0-9, _).
n) Matching Any Non-AlphaNumeric Character:
\W instructs QTP to match any character other than alphanumeric characters and underscores.
o) Combining Regular Expression Operators:
We can combine regular expression operators in a single expression to achieve the exact search criteria we need.
For example,
start.*
Matches start, started, starting, starter, and so forth.
we can use a combination of brackets and an asterisk to limit the search to a combination of non-numeric characters.
For example:
[a-zA-Z]*
To match any number between 0 and 1200, we need to match numbers with 1 digit, 2 digits, 3 digits, or 4 digits between 1000-1200.
The regular expression below matches any number between 0 and 1200.
([0-9]?[0-9]?[0-9]|1[01][0-9][0-9]|1200)
Friday, August 26, 2011
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment