[Lazarus] What's the correct way to use TRegexEngine?
silvioprog
silvioprog at gmail.com
Thu Dec 22 14:55:37 CET 2011
Hi,
The correct way to use RegEx is like I'm showing below? (I saw this
code in bugtracker)
uses
RegEx;
procedure TForm1.Button1Click(Sender: TObject);
var
VRegEx: TRegexEngine;
VErrorCode: TRegexError;
VOffset, VErrorPos, VMatchPos: Integer;
begin
VRegEx := TRegexEngine.Create('[0-9]');
try
try
VErrorPos := 0;
VMatchPos := 0;
VErrorCode := recNone;
if VRegEx.Parse(VErrorPos, VErrorCode) then
begin
VOffset := 1; //<<<------ I use 1 or 0 here? :/
if VRegEx.MatchString('ABC123', VMatchPos, VOffset) then
ShowMessage('Match')
else
ShowMessage('No Match');
end
else
ShowMessage('Parse Failed');
except
on E: Exception do
ShowMessage('RegEx ERROR: ' + E.Message);
end;
finally
VRegEx.Free;
end;
end;
Thx.
--
Silvio Clécio
====================================
Site - <silvioprog.com.br>
LazSolutions - <code.google.com/p/lazsolutions>
====================================
More information about the Lazarus
mailing list