Hi,

I'm using RegExpr to parse some parts, just SOME parts, of a HTML and works
perfectly. But, in one case I need identify a "pattern" to reuse using new
"values".

Please, see the example (using Lazarus) bellow:

procedure TForm1.Button1Click(Sender: TObject);
var
  InputStr: string;
  r: TRegExpr;
begin
  r:= TRegExpr.Create;
  try
    InputStr := '<a href="/3604669/trabalho-28-07-2014-pg-1" title="Página
1, pg 1, 28/07/2014"> 28/07/2014 </a>';
    r.Expression := '\/([0-9]+)\/.*?pg\-(\d+).*?"';
    r.Exec(InputStr);
    ShowMessage(r.Match[0]); // = /3604669/trabalho-28-07-2014-pg-1"
    ShowMessage(r.Match[1]); // = 3604669
    ShowMessage(r.Match[2]); // = 1
  finally
    r.Free;
  end;
end;

The results are OK.
I need to replace the position #1 and #2 with something like:
#p1# and  #p2#

So, in other words, I need a result like this:
Pattern = /#p1#/trabalho-28-07-2014-pg-#p2#"

I tried to use r.Replace() or r.Substitute() but I think these methods
don't do I want.

Is possible?

--
Marcos Douglas
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to