Description
Use the RegExpr.Expression
property to set or get the current regular expression.
Declaration
RegExprObj.Expression
Read-Write Property | String |
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
A string that contains the current regular expression.
Regular expression consists of literal characters and regular expression operators. See a list of regular expression tokens in the Regular Expressions Syntax topic.
Remarks
If the Expression
property changed, it is automatically converted into the engine’s internal representation when you call Exec
, ExecNext
, ExecPos
, Substitute
methods.
Use the RegExpr.Compile
method for the enforced expression conversion.
Example
The following example demonstrates how to specify a regular expression pattern.
DelphiScript
var
MyRegExpr : OleVariant;
begin
MyRegExpr := HISUtils.RegExpr;
// Initializes the InputString property
MyRegExpr.InputString := 'Please e-mail us at [email protected] or [email protected]';
// Initializes the Expression property
MyRegExpr.Expression := '[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}';
MyRegExpr.ExecPos;
// Posts the first matching text to the test log
Log.Message(MyRegExpr.Match[0]);
end;
See Also
Using Regular Expressions in Scripts
Using Regular Expressions in Scripts
Compile Method
CompilerErrorPos Property