[fpc-pascal] RegExpr - replace

leledumbo leledumbo_cool at yahoo.co.id
Sun Sep 7 14:36:33 CEST 2014


If I'm not mistaken what you want:

{$mode objfpc}{$H+}
uses
  RegExpr;
var
  InputStr: string;
  r: TRegExpr;
begin
  r:= TRegExpr.Create;
  try
    InputStr := ' 28/07/2014 </3604669/trabalho-28-07-2014-pg-1>  ';
    r.Expression := '(\/)([0-9]+)(\/.*?pg\-)(\d+).*?"';
    r.Exec(InputStr);
    WriteLn(r.Substitute('$1$4$3$2'));
  finally
    r.Free;
  end;
end.

should do it.



--
View this message in context: http://free-pascal-general.1045716.n5.nabble.com/RegExpr-replace-tp5719987p5719989.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.



More information about the fpc-pascal mailing list