git-svn-id: trunk@39555 -
This commit is contained in:
michael 2018-08-03 17:54:11 +00:00
parent 32c307e9ce
commit f575eafa1e

View File

@ -710,7 +710,7 @@ const
function StrPCopy (Dest: PRegExprChar; const Source: RegExprString): PRegExprChar;
var
i, Len : PtrInt;
Len : PtrInt;
begin
Len := length (Source); //###0.932
if Len>0 then
@ -721,7 +721,7 @@ function StrPCopy (Dest: PRegExprChar; const Source: RegExprString): PRegExprCha
--------------------------------------------------------------}
function StrLCopy (Dest, Source: PRegExprChar; MaxLen: PtrUInt): PRegExprChar;
var i: PtrInt;
begin
if MaxLen>0 then
move(Source[0],Dest[0],MaxLen*sizeof(ReChar));
@ -730,45 +730,53 @@ function StrLCopy (Dest, Source: PRegExprChar; MaxLen: PtrUInt): PRegExprChar;
--------------------------------------------------------------}
function StrLen (Str: PRegExprChar): PtrUInt;
begin
Result:=0;
while Str [result] <> #0
do Inc (Result);
while Str [result] <> #0 do
Inc (Result);
end; { of function StrLen
--------------------------------------------------------------}
function StrPos (Str1, Str2: PRegExprChar): PRegExprChar;
var n: PtrInt;
var
n: PtrInt;
begin
Result := nil;
n := Pos (RegExprString (Str2), RegExprString (Str1));
if n = 0
then EXIT;
if n = 0 then
EXIT;
Result := Str1 + n - 1;
end; { of function StrPos
--------------------------------------------------------------}
function StrLComp (Str1, Str2: PRegExprChar; MaxLen: PtrUInt): PtrInt;
var S1, S2: RegExprString;
var
S1, S2: RegExprString;
begin
S1 := Str1;
S2 := Str2;
if Copy (S1, 1, MaxLen) > Copy (S2, 1, MaxLen)
then Result := 1
if Copy (S1, 1, MaxLen) > Copy (S2, 1, MaxLen) then
Result := 1
else if Copy (S1, 1, MaxLen) < Copy (S2, 1, MaxLen) then
Result := -1
else
if Copy (S1, 1, MaxLen) < Copy (S2, 1, MaxLen)
then Result := -1
else Result := 0;
Result := 0;
end; { function StrLComp
--------------------------------------------------------------}
function StrScan (Str: PRegExprChar; Chr: WideChar): PRegExprChar;
begin
Result := nil;
while (Str^ <> #0) and (Str^ <> Chr)
do Inc (Str);
if (Str^ <> #0)
then Result := Str;
while (Str^ <> #0) and (Str^ <> Chr) do
Inc (Str);
if (Str^ <> #0) then
Result := Str;
end; { of function StrScan
--------------------------------------------------------------}
@ -780,26 +788,28 @@ function StrScan (Str: PRegExprChar; Chr: WideChar): PRegExprChar;
{=============================================================}
function ExecRegExpr (const ARegExpr, AInputStr : RegExprString) : boolean;
var r : TRegExpr;
begin
r := TRegExpr.Create;
With TRegExpr.Create do
try
r.Expression := ARegExpr;
Result := r.Exec (AInputStr);
finally r.Free;
Expression := ARegExpr;
Result := Exec (AInputStr);
finally
Free;
end;
end; { of function ExecRegExpr
--------------------------------------------------------------}
procedure SplitRegExpr (const ARegExpr, AInputStr : RegExprString; APieces : TStrings);
var r : TRegExpr;
begin
APieces.Clear;
r := TRegExpr.Create;
With TRegExpr.Create do
try
r.Expression := ARegExpr;
r.Split (AInputStr, APieces);
finally r.Free;
Expression := ARegExpr;
Split (AInputStr, APieces);
finally
Free;
end;
end; { of procedure SplitRegExpr
--------------------------------------------------------------}
@ -807,10 +817,12 @@ procedure SplitRegExpr (const ARegExpr, AInputStr : RegExprString; APieces : TSt
function ReplaceRegExpr (const ARegExpr, AInputStr, AReplaceStr : RegExprString;
AUseSubstitution : boolean{$IFDEF DefParam}= False{$ENDIF}) : RegExprString;
begin
with TRegExpr.Create do try
with TRegExpr.Create do
try
Expression := ARegExpr;
Result := Replace (AInputStr, AReplaceStr, AUseSubstitution);
finally Free;
finally
Free;
end;
end; { of function ReplaceRegExpr
--------------------------------------------------------------}