Forum > Packages and Libraries

Problem with the TRegExpr Library

(1/1)

IndianaJones:
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]

eny:
My crystal ball says you didn't call Exec.

IndianaJones:

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;

IndianaJones:
Bump

eny:

--- Quote from: IndianaJones on August 01, 2011, 10:38:25 am ---Bump

--- End quote ---
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.

Navigation

[0] Message Index

Go to full version