fpc/packages/regexpr/examples/demowd.pp
Michaël Van Canneyt 49e41873b0 * PChar -> PAnsiChar
2023-07-15 18:22:39 +02:00

28 lines
595 B
ObjectPascal

{
Program to demonstrate UseUnicodeWordDetection property.
Run this program as
testwd
testwd 1
to see the difference
}
{$mode objfpc}
{$h+}
uses cwstring,uregexpr;
Function ReplaceRegExpr(ARegExpr, AInputStr, AReplaceStr : Unicodestring) : AnsiString;
begin
with TRegExpr.Create do
try
UseUnicodeWordDetection:=ParamStr(1)='1';
Expression := ARegExpr;
Result:=Replace (AInputStr, AReplaceStr, True);
finally
Free;
end;
end;
begin
Writeln(ReplaceRegExpr('\w+', UTF8Decode('test слово ŕáćéí ϸϬϛ ュユョ'), '<$0>'));
end.