LastError Property

Applies to TestComplete 14.72, last modified on January 19, 2021


Use the RegExpr.LastError property to get the code of the last error that occurred during the regular expression compilation. To get the error description use the ErrorMsg property. To get the position in the regular expression where the error occurred use the CompilerErrorPos property.



Read-Only Property Integer
RegExprObj An expression, variable or parameter that specifies a reference to a RegExpr object

Applies To

The property is applied to the following object:

Property Value

The error code.

This property returns 0 if regular expression compiled successfully.


The following example demonstrates how to use the RegExpr.Compile method to force expression conversion and to get conversion errors that occur during compilation.


procedure CompileSample;
  MyRegExp: OleVariant;
  Mes: string;
  Err, Pos: integer;

    // Specifies a regular expression
    MyRegExp.Expression := '[]';
    // Forces expression conversion
    // Performs operations over text
    // If a compilation error occurs…
    // Obtains the code of the occurred error
    Err := MyRegExp.LastError;
    // Obtains the description of the occurred error
    Mes := MyRegExp.ErrorMsg[Err];
    // Obtains the position, in the regular expression, where the error occurred
    Pos := MyRegExp.CompilerErrorPos;
    // Posts information on the error to the test log
    Log.Error('Error: ' + aqConvert.IntToStr(Err) + ' ' + Mes + ' (pos ' + aqConvert.IntToStr(Pos) + ')');

See Also

Regular Expressions Syntax
Using Regular Expressions in Scripts
Expression Property
Compile Method
ErrorMsg Property
CompilerErrorPos Property

Highlight search results