Find out if Var reg:tperlregex exists;
BEGIN REG: = Tperlregex.create (nil); Reg.
Subject: = ' CodeGear Delphi 2007 for Win32 '; Reg.
RegEx: = ' \d '; If Reg.
Match then ShowMessage (' found ') Else showmessage (' not found ');
Freeandnil (REG);
End
Find whether existence (Method 2) var Reg:tperlregex;
BEGIN REG: = Tperlregex.create (nil); Reg.
Subject: = ' CodeGear Delphi 2007 for Win32 '; Reg.
RegEx: = ' \d '; Reg. Match; Performs a lookup if Reg.
Foundmatch then//boolean variable Foundmatch will tell us if the lookup has a result showmessage (' found ') Else showmessage (' not found ');
Freeandnil (REG);
End
Displays the first var reg:tperlregex found;
BEGIN REG: = Tperlregex.create (nil); Reg.
Subject: = ' CodeGear Delphi 2007 for Win32 '; Reg.
RegEx: = ' \d '; If Reg. Match then ShowMessage (Reg.
Matchedexpression)//2 Else showmessage (' not found ');
Freeandnil (REG);
End
Show each and every sum of Var reg:tperlregex found separately; Num:integer;
Use NUM to count begin reg: = Tperlregex.create (nil); Reg.
Subject: = ' CodeGear Delphi 2007 for Win32 '; Reg.
RegEx: = ' \d ';
num: = 0; While Reg. Matchagain do//matchagain is the next begin ShowMessage (Reg. Matchedexpression);
will be shown separately: 2 0 0 7 3 2 Inc (num);
End ShowMessage (IntToStr (num));
6 Freeandnil (REG);
End
Show each and total found (another) var Reg:tperlregex; Num:integer;
Use NUM to count begin reg: = Tperlregex.create (nil); Reg.
Subject: = ' CodeGear Delphi 2007 for Win32 '; Reg.
RegEx: = ' \d ';
num: = 0; If Reg. Match THEN BEGIN repeat ShowMessage (Reg. Matchedexpression);
will be shown separately: 2 0 0 7 3 2 Inc (num); Until (not Reg.
Matchagain);
End ShowMessage (IntToStr (num));
6 Freeandnil (REG);
End
The position and length of the target string Var Reg:tperlregex;
BEGIN REG: = Tperlregex.create (nil); Reg.
Subject: = ' CodeGear Delphi 2007 for Win32 '; Reg.
RegEx: = ' Delphi '; While Reg. Matchagain do//It is obvious that this example can only find one result begin ShowMessage (Reg. Matchedexpression); Found string: Delphi showmessage (INTTOSTR) (Reg. Matchedexpressionoffset)); Where it is: showMessage (IntToStr (Reg. Matchedexpressionlength));
Its length: 6 end;
Freeandnil (REG); End