mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-08 07:46:03 +02:00
Implemented missing StringReplace function
This commit is contained in:
parent
4679852c88
commit
076d02873e
@ -1223,6 +1223,47 @@ begin
|
||||
Dec(Result);
|
||||
end;
|
||||
|
||||
function StringReplace(const S, OldPattern, NewPattern: string; Flags: TReplaceFlags): string;
|
||||
|
||||
var
|
||||
Srch,OldP,RemS: string; // Srch and Oldp can contain uppercase versions of S,OldPattern
|
||||
P : Integer;
|
||||
|
||||
begin
|
||||
Srch:=S;
|
||||
OldP:=OldPattern;
|
||||
if rfIgnoreCase in Flags then
|
||||
begin
|
||||
Srch:=UpperCase(Srch);
|
||||
OldP:=UpperCase(OldP);
|
||||
end;
|
||||
RemS:=S;
|
||||
Result:='';
|
||||
while (Length(Srch)<>0) do
|
||||
begin
|
||||
P:=Pos(OldP, Srch);
|
||||
if P=0 then
|
||||
begin
|
||||
Result:=Result+RemS;
|
||||
Srch:='';
|
||||
end
|
||||
else
|
||||
begin
|
||||
Result:=Result+Copy(RemS,1,P-1)+NewPattern;
|
||||
P:=P+Length(OldP);
|
||||
RemS:=Copy(RemS,P,Length(RemS)-P+1);
|
||||
if not (rfReplaceAll in Flags) then
|
||||
begin
|
||||
Result:=Result+RemS;
|
||||
Srch:='';
|
||||
end
|
||||
else
|
||||
Srch:=Copy(Srch,P,Length(Srch)-P+1);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
{
|
||||
Case Translation Tables
|
||||
Can be used in internationalization support.
|
||||
@ -1234,6 +1275,8 @@ end;
|
||||
of the OS corresponds to the one you make changes to
|
||||
}
|
||||
|
||||
|
||||
|
||||
const
|
||||
{ upper case translation table for character set 850 }
|
||||
CP850UCT: array[128..255] of char =
|
||||
@ -1281,7 +1324,17 @@ const
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.12 2001-08-01 21:44:20 peter
|
||||
Revision 1.13 2001-09-20 14:38:41 michael
|
||||
Implemented missing StringReplace function
|
||||
|
||||
Revision 1.12 2001/08/01 21:44:20 peter
|
||||
Revision 1.1.2.9 2001/09/20 14:35:34 michael
|
||||
Implemented missing StringReplace function
|
||||
|
||||
Revision 1.1.2.8 2001/08/14 20:06:23 carl
|
||||
-* replace ifdef linux -> ifdef unix
|
||||
|
||||
Revision 1.1.2.7 2001/08/01 21:45:22 peter
|
||||
* fix thousend separator when no decimal separator is available
|
||||
* allow precision to be left away like %10.n
|
||||
|
||||
|
@ -30,12 +30,17 @@ type
|
||||
|
||||
{ For FloatToText }
|
||||
TFloatFormat = (ffGeneral, ffExponent, ffFixed, ffNumber, ffCurrency);
|
||||
<<<<<<< sysstrh.inc
|
||||
|
||||
const
|
||||
{ For floattodatetime }
|
||||
MinDateTime: TDateTime = -657434.0; { 01/01/0100 12:00:00.000 AM }
|
||||
MaxDateTime: TDateTime = 2958465.99999; { 12/31/9999 11:59:59.999 PM }
|
||||
|
||||
=======
|
||||
|
||||
|
||||
>>>>>>> 1.1.2.2
|
||||
function NewStr(const S: string): PString;
|
||||
procedure DisposeStr(S: PString);
|
||||
procedure AssignStr(var P: PString; const S: string);
|
||||
@ -106,9 +111,18 @@ function BCDToInt(Value: integer): integer;
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.6 2000-12-09 10:39:50 florian
|
||||
Revision 1.7 2001-09-20 14:38:41 michael
|
||||
Implemented missing StringReplace function
|
||||
|
||||
Revision 1.6 2000/12/09 10:39:50 florian
|
||||
* fixed merging problem
|
||||
|
||||
Revision 1.1.2.2 2000/12/07 21:48:58 michael
|
||||
+ Added LastDelimiter function
|
||||
|
||||
Revision 1.1.2.1 2000/08/09 19:31:03 peter
|
||||
* int64 updates from Marco
|
||||
|
||||
Revision 1.5 2000/12/07 21:58:30 michael
|
||||
+ Merged lastdelimiter from fixbranch
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user