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