The Delphi regular expression starts in Delphi uses the regular expression, at present Perlregex should be the first choice, prepares thoroughly and meticulously to study it.
Official website: http://www.regular-expressions.info/delphi.html
Direct download: Http://www.regular-expressions.info/download/TPerlRegEx.zip
Installation method:
1, first to unpack the Tperlregex folder put a suitable place, I placed in the Delphi Imports directory.
2, the current version of the latest for Win32 is the Delphi 2006, 2007 can also be used.
Open PERLREGEXD2006.DPK, prompt missing resource file, it doesn't matter;
Right-click on the PERLREGEXD2006.BPL in the Project Manager window to execute the Install;
At this point in the Tool Palette list already has the Tperlregex, in the Jgsoft group.
3. Environment options, Tools, Options, Delphi options, Library-win32, Library Path,
Add Path: ... \imports\tperlregex
4, can be used! Either directly uses Perlregex or add from Tool Palette.
If you don't like the way Tool Palette is added, you can omit the second step.
Planned learning steps: 1, regular grammar; 2, Tperlregex function.
//test First:usesPerlregex;//uses Regular Expression UnitprocedureTform1.formcreate (Sender:tobject);varReg:tperlregex;//Declare regular expression variablesbeginReg: = Tperlregex.create (Nil);//EstablishedReg. Subject: =' SSsS ';//This is the source string to replaceReg. RegEx: =' s ';//This is an expression, here is the substring ready to be replacedReg. Replacement: ="';//To replace with a new stringReg. ReplaceAll;//Perform all substitutionsShowMessage (Reg. Subject);//Return replacement result: s SFreeandnil (REG);//or Reg. FreeEnd;
Delphi Regular expression start-up