[Lazarus] How to use TRegExpr class (in synregexpr.pas)
FreeMan
freeman35 at delphiturkiye.com
Thu Oct 24 14:43:46 CEST 2013
Hello,
Lazarus Revision 43315
TRegExpr class in "/opt/lazarus/components/synedit/synregexpr.pas"
I need check IP address, my IP4OK function for this. If I sent
variable result is false, but sent parameter like '127.0.0.1' result is
true, what is wrong?
EDT_IP: TMaskEdit;
......
EDT_IP.EditMask:= '!999.999.999.999;1; ';
......
function IP4OK(pT: string): boolean;
var r : TRegExpr;
i : integer;
IP : String;
begin
r := TRegExpr.Create;
r.Expression := '^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$';
IP := pT;
Result := r.Exec(pT); //Line 1.
Result := r.Exec(IP); //Line 2.
IP := '127.0.0.1';
Result := r.Exec(IP); //Line 3.
Result := r.Exec('127.0.0.1'); //Line 4.
r.Free;
end;
firts test:
if IP4OK('127.0.0.1') then .... if I use this function like this, "//
Line X. " all r.Exec function return True
second test via vairable:
run project and type "127.0.0.1" in EDT_IP then trigger
if IP4OK(EDT_IP.Text) then .... if I use this function like this,
"// Line 1. " r.Exec function return FALSE
"// Line 2. " r.Exec function return FALSE
"// Line 3. " r.Exec function return TRUE
"// Line 4. " r.Exec function return TRUE
More information about the Lazarus
mailing list