码迷,mamicode.com
首页 > Windows程序 > 详细

Delphi 正则表达式之TPerlRegEx 类的属性与方法(3): Start、Stop

时间:2014-10-29 18:41:03      阅读:220      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   os   ar   sp   strong   div   

//设定搜索范围: Start、Stop
var
  reg: TPerlRegEx;
begin
  reg := TPerlRegEx.Create(nil);

  reg.Subject := ‘ababab‘;
  reg.RegEx   := ‘ab‘;
  reg.Replacement := ‘◆‘;

  reg.Start := 1;
  reg.Stop := 2;
  while reg.MatchAgain do
  begin
    reg.Replace;
  end;
  ShowMessage(reg.Subject); //返回: ◆abab


  reg.Subject := ‘ababab‘;
  reg.Start := 3;
  reg.Stop := 4;
  while reg.MatchAgain do
  begin
    reg.Replace;
  end;
  ShowMessage(reg.Subject); //返回: ab◆ab


  reg.Subject := ‘ababab‘;
  reg.Start := 5;
  reg.Stop := 6;
  while reg.MatchAgain do
  begin
    reg.Replace;
  end;
  ShowMessage(reg.Subject); //返回: abab◆

  FreeAndNil(reg);
end;

 

Delphi 正则表达式之TPerlRegEx 类的属性与方法(3): Start、Stop

标签:style   blog   http   color   os   ar   sp   strong   div   

原文地址:http://www.cnblogs.com/honeynm/p/4059928.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!