ExecPos Method

Applies to TestComplete 14.80, last modified on April 15, 2021


The RegExpr.ExecPos method searches the input string starting from the AOffset position for the text 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
AOffset [in]    Optional    Integer Default value: 1   
Result Boolean

Applies To

The method is applied to the following object:


The method has the following parameter:


An integer specifying the input string character position where the search operation started.

Result Value

Returns True if the text matching the expression 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 the input string before calling the ExecPos method, otherwise an error occurs.


The following example demonstrates how you can use the RegExpr.ExecPos method to specify whether the input string that starts from the specified position contains the text that matches the pattern.


procedure ExecPosSample();
  MyRegExpr: OleVariant;
  Input, Expr: string;

  MyRegExpr := HISUtils.RegExpr;
  Input := 'TestComplete project suite files have the .pjs extension.';
  // This expression specifies the extension pattern
  Expr := '(\.[\w]+)';
  MyRegExpr.InputString := Input;
  MyRegExpr.Expression : = Expr;

  // Checks whether the input string contains matching text after the specified position
  if MyRegExpr.ExecPos(40) then
    Log.Message('The matching text is found after the specified position')
    Log.Message('No matching text was found after the specified position');


See Also

Regular Expressions Syntax
Using Regular Expressions in Scripts
Expression Property
InputString Property
Match Property
Exec Method
ExecNext Method

Highlight search results