[Lazarus] Regex expressions

Dave Coventry dgcoventry at gmail.com
Wed Sep 8 08:52:37 CEST 2010


Hi Maik,

On 8 September 2010 08:04, Maik Wojcieszak <maikwo at googlemail.com> wrote:
> I've tried some regex units implemented in pascal but they are
> either not complete or buggy or slow.
> The best I've found was PCRE which is kind of a standard in many
> scripting languages.
> I'm not sure if there is a lazarus wrapper but I'm using it with delphi.
>
> http://www.renatomancuso.com/software/dpcre/dpcre.htm


This is what I've got.

It works, but it's a bit tacky!

  i:=Pos('\U+',mPCharArray);
  while i>0 do
  begin
    subS:=Copy(mPCharArray,i+3,4);
    mainString:=mPCharArray;
    Delete(mainString,i,7);
    Insert(chr(Hex2Dec(subS)),mainString,i);
    mPCharArray:=PChar(mainString);
    i:=Pos('\U+',mPCharArray);
  end;

I was hoping that someone could suggest something a little more elegant!




More information about the Lazarus mailing list