Defining Regular Expressions


In QTP, you can use regular expressions only for values of type string. In QTP, you can define a regular expression for a constant value, a Data Table parameter value, an Environment parameter value, or a property value in a programmatic description.

You can define a regular expression by entering the regular expression syntax for the string in the Value box in the Constant Value Options dialog box or the Parameter Options dialog box. You instruct QTP to treat the value as a regular expression by selecting the Regular Expression check box.
All programmatic description property values are automatically treated as regular expressions.
By default, QTP treats all characters in a regular expression literally, except for the period (.), hyphen (-), asterisk (*), caret (^), brackets ([ ]), parentheses (()), dollar sign ($), vertical line (|), plus sign (+), question mark (?), and backslash (\). When one of these special characters is preceded by a backslash (\), QTP treats it as a literal character.
If you enter a special character in the Value box of the Constant Value Options or the Parameter Options dialog box, QTP asks you if you want to add a backslash (\) before each special character.
If you click Yes, a backslash (\) is added before the special character to instruct QTP to treat the character literally. If you clickNo, QTP treats the special character as a regular expression character.

No comments:

Post a Comment