Lazarus
Programming => Packages and Libraries => Topic started 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]
-
My crystal ball says you didn't call Exec.
-
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;
-
Bump
-
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.