ExecNext Method

Applies to TestComplete 15.65, last modified on June 26, 2024


The RegExpr.ExecNext method searches the input string for the next text occurrence that matches the regular expression pattern. To get a portion of the text that matches the pattern, use the Match property.



RegExprObj An expression, variable or parameter that specifies a reference to a RegExpr object
Result Boolean

Applies To

The method is applied to the following object:

Result Value

Returns True if the text matches the expression that was found and False otherwise.


You should initialize the Expression property with the regular expression and the InputString property (explicitly or implicitly via previous Exec call) with input string before calling the ExecNext method, otherwise an error occurs.


The following example demonstrates how to use the RegExpr.ExecNext method to iterate through the input text untill all matches are found.


procedure ExecSample;
  MyRegExp: OleVariant;
  ResStr: String;

  //This expression specifies an e-mail address pattern
  if MyRegExp.Exec('Please e-mail us at [email protected] or [email protected]') then
      ResStr := ResStr + MyRegExp.Match[0] + '; ';
    Until not MyRegExp.ExecNext;
  Log.Message('These e-mails were extracted: '+ResStr);
  //Posts the following to the log:
  //'These e-mails were extracted: [email protected]; [email protected]; '

See Also

Using Regular Expressions in Scripts
Using Regular Expressions in Scripts
Expression Property
InputString Property
Match Property
Exec Method
ExecPos Method

Highlight search results