The properties and methods of the Tperlregex class of the Delphi formula (1) Find

Source: Internet
Author: User
Tags count integer win32
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.