RegExpr Object

Applies to TestComplete 14.0, last modified on January 23, 2019

Description

The RegExpr object allows you to use regular expressions in DelphiScript. This allows you to 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.

Please read the Regular Expressions Syntax topic to learn how to compose regular expressions.

The HISUtils object is available only if the HISUtils plugin (<TestComplete>\Bin\Extensions\tcHISUtils.pls) is installed. For information on how to install plugins in TestComplete, see Installing Extensions.

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
Regular Expressions Syntax

Highlight search results