Delphi 正则表达式之TPerlRegEx 类的属性与方法(3): Start、Stop
2020-12-13 14:14
标签:style blog http color os ar sp strong div Delphi 正则表达式之TPerlRegEx 类的属性与方法(3): Start、Stop 标签:style blog http color os ar sp strong div 原文地址:http://www.cnblogs.com/honeynm/p/4059928.htmlDelphi 正则表达式之TPerlRegEx 类的属性与方法(3): Start、Stop
//设定搜索范围: 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;
上一篇:怎样拷贝整个目录并且忽略部分文件及目录(包括windows)?
下一篇:Java xml出现错误 javax.xml.transform.TransformerException: java.lang.NullPointerException
文章标题:Delphi 正则表达式之TPerlRegEx 类的属性与方法(3): Start、Stop
文章链接:http://soscw.com/essay/33860.html