Hi, I wanted to use regular expressions to search for UTF8 characters, but I didn't succeed.
The results returned by the following code are not what I expected:
program Project1;
{$mode objfpc}{$H+}
uses
Classes,
RegExpr;
var
Str, Pattern: string;
expr: TRegExpr;
Found: boolean;
begin
Str := '一二三四五六七八九十';
Pattern := '[三六]';
expr := TRegExpr.Create(Pattern);
Found := expr.Exec(Str);
while Found do begin
Write(expr.MatchPos[0], ' ');
Found := expr.ExecNext;
end;
expr.Free;
end.
I need the result is "3 6", but it is "1 2 4 7 8 9 10 13 16 17 18 19 20 22 23 25 28", What should I do? Can someone help me?