Lazarus

Programming => Packages and Libraries => Topic started by: IndianaJones on July 31, 2011, 12:22:59 pm

Title: Problem with the TRegExpr Library
Post by: IndianaJones on July 31, 2011, 12:22:59 pm
Hi all,
When I try to split strings, get the following error. Any idea how can i overcome this error.
Thanks.

TRegExpr(exec): ExecNext without Exec[Pos]
Title: Re: Problem with the TRegExpr Library
Post by: eny on July 31, 2011, 12:44:18 pm
My crystal ball says you didn't call Exec.
Title: Re: Problem with the TRegExpr Library
Post by: IndianaJones on July 31, 2011, 01:44:59 pm

I tried with the Match and it works normal but when I add the Split syntax, the same error occurs. Thanks

      re:=TRegExpr.Create;
      try
        re.Expression := 'example expression';
        if re.Exec(tmpstr.Text) then
        repeat
//          re.Split(tmpstr.Text, ostr);
//          Memo2.Lines.Add(ostr[1]);
          Memo2.Lines.Add(re.Match[0]);
        until not re.ExecNext;
      finally
        re.Free;
      end;
Title: Re: Problem with the TRegExpr Library
Post by: IndianaJones on August 01, 2011, 10:38:25 am
Bump
Title: Re: Problem with the TRegExpr Library
Post by: eny on August 05, 2011, 08:52:49 pm
Bump
Ow, my head  :D

Finally had some time to investigate this.
You shouldn't call ExecNext because Split already parses the complete text.
ostr contains all returned lines.
Instead of only adding ostr[1], add all lines to the memo box that were returned.
TinyPortal © 2005-2018