The properties and methods of the Tperlregex class of Delphi Regular Expressions (1): Finding

Source: Internet
Author: User

The properties and methods of the Tperlregex class of Delphi Regular Expressions (1): Finding
//Find out if there is var reg:tperlregex;  begin Reg: = tperlregex.create (nil' codegear Delphi for Win32 '; Reg. RegEx  ' \d 'if then ShowMessage (' found 'else showmessage (  ' not found '); Freeandnil (REG); End;
//Lookup exists (Method 2)varReg:tperlregex;beginReg: = Tperlregex.create (Nil); Reg. Subject: =' CodeGear Delphi for Win32 '; Reg. RegEx: =' \d '; Reg. Match;//Perform findifReg. Foundmatch Then//Boolean variable Foundmatch will tell us to find out if there are any resultsShowMessage (' found it ')ElseShowMessage (' not found '); Freeandnil (REG);End;
//Show the first one found var reg:tperlregex;  begin Reg: = tperlregex.create (nil' codegear Delphi for Win32 '; Reg.  RegEx  ' \d 'ifthen//2Else showmessage (' not found '); Freeandnil (REG); End;
//show each and every number found separatelyvarReg:tperlregex; Num:integer;//Count with NumbeginReg: = Tperlregex.create (Nil); Reg. Subject: =' CodeGear Delphi for Win32 '; Reg. RegEx: =' \d '; Num: =0; whileReg. Matchagain Do//matchagain is the next beginShowMessage (Reg. Matchedexpression);//will be displayed separately: 2 0 0 7 3 2Inc. (NUM);End; ShowMessage (IntToStr (num));//6Freeandnil (REG);End;
//Show each of the found and total (another)varReg:tperlregex; Num:integer;//Count with NumbeginReg: = Tperlregex.create (Nil); Reg. Subject: =' CodeGear Delphi for Win32 '; Reg. RegEx: =' \d '; Num: =0;ifReg. Match ThenbeginRepeatShowMessage (Reg. Matchedexpression);//will be displayed separately: 2 0 0 7 3 2Inc. (NUM);until( notReg. Matchagain);End; ShowMessage (IntToStr (num));//6Freeandnil (REG);End;
//The position and length of the target stringvarReg:tperlregex;beginReg: = Tperlregex.create (Nil); Reg. Subject: =' CodeGear Delphi for Win32 '; Reg. RegEx: =' Delphi '; whileReg. Matchagain Do//It is clear that this example can only find one resultbeginShowMessage (Reg. Matchedexpression);//String found: DelphiShowMessage (IntToStr (Reg. Matchedexpressionoffset));//Where it is:ShowMessage (IntToStr (Reg. Matchedexpressionlength));//Its length: 6End; Freeandnil (REG);End;

The properties and methods of the Tperlregex class of Delphi Regular Expressions (1): Finding

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.