Delphi 正则表达式之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;

 

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

上一篇:如何使用加密的Payload来识别并利用SQL注入漏洞


下一篇:【漏洞复现】Apache Solr Velocity 注入远程命令执行漏洞 (CVE-2019-17558)