Regular Expressions in QTP in Testing

Regular Expressions enable QTP to identify text strings and identify objects with various values.

We can use Regular Expression during:

  • parameterizing a step
  • creating checkpoints with various values
  • defining the property values of an object in dialog boxes or in programmatic descriptions

We can use Regular Expression if we want to create a text checkpoint on a fax order text strings, as the displayed fax order changes.


 A Regular Expression is a string which specifies a complex search phrase using special characters like period (.), asterisk (*), caret (^) and brackets ([]).


How to define Regular Expressions

We can define a Regular Expression by entering the Regular Expression syntax for the string in the parameter options dialog box or in the Value box in the constant Value Options dialog box. By selecting the Regular Expression check box we can instruct QucikTest to treat the value as a Regular Expression.


Except for hyphen (-), asterisk (*), brackets ([]), parenthesis (()),  vertical line (|), plus sign (+), question mark (?), period (.), caret (^), dollar sign ($) and backslash (\), QTP treats all characters in a Regular Expression literally by default.


If we enter a special character in the parameter option's dialog box or in the Value box of the constant value Options, then QTP asks you whether you want to add a backlash (\) before a special character. If we click on No, QTP treats the special characters as a Regular Expression character or if you click on Yes, QTP treats the special character literally.