RegExpr Object

Applies to TestComplete 15.62, last modified on March 19, 2024

Description

The RegExpr object allows using regular expressions in DelphiScript. This way, you can perform search and replace operations over the text fragments that match the specified regular expression pattern. Also, you can use regular expressions to validate user input data.

To get the object in your tests, use the HISUtils.RegExpr property.

Please read the Using Regular Expressions in Scripts topic to learn how to compose regular expressions.

Requirements

The RegExpr object is available only if the HISUtils plugin is enabled.

This plugin is installed and enabled by default during the TestComplete installation. You can check the plugin status in the File > Install Extensions dialog in TestComplete. You can find the plugin in the Common group.

Members

Example

The following code obtains the text that matches a regular expression and posts the text to the test log.

DelphiScript

procedure Sample;
var
  MyRegExpr : OleVariant;
begin
  MyRegExpr := HISUtils.RegExpr;
  MyRegExpr.InputString := 'Please e-mail us at [email protected] or [email protected]';
  MyRegExpr.Expression := '[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}';
  MyRegExpr.ExecPos;
  // Posts the first matching segment of the text to the test log
  Log.Message(MyRegExpr.Match[0]);
end;

See Also

HISUtils Object
Installing Extensions
Using Regular Expressions in Scripts
Using Regular Expressions in Scripts

Highlight search results