[fpc-pascal] regex unit doesn't find matches???

Michalis Kamburelis michalis.kambi at gmail.com
Mon Dec 1 13:00:01 CET 2008


Graeme Geldenhuys wrote:
> Hi,
> 
> I'm using the following regular expression:   'foob.*r'
> Calling MatchString() against each of the items in the stringlist, I
> expected it to match 3 items. Instead it only matches the first item
> and fails all the rest.  Why???
> 
> 
> --------------[  source code ]-------------------
>   sl := TStringList.Create;
>   sl.Add('1st foobr Item');
>   sl.Add('2nd Item');
>   sl.Add('3rd Item');
>   sl.Add('4th foobaoeuaor Item');
>   sl.Add('5th foobar Item');
> 
>   r := TRegexEngine.Create('foob.*r');
>   x := 0;
>   y := 0;

You should reset x, y within the loop (before each r.MatchString), not here.

Michalis



More information about the fpc-pascal mailing list