Unit Unit1;
Interface
Uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
Type
TForm1 = class(TForm)
function Replace(Expression,Find,Replace:String):string;
procedure FormCreate(Sender: TObject);
End;
Var
Form1: TForm1;
Implementation
{$R *.dfm}
function Tform1.Replace(Expression,Find,Replace:String):string;
Var
c: integer;
sTemp, sTemp2: string;
Begin
sTemp := Expression;
c := pos(Find,sTemp);
while c <> 0 do
Begin
sTemp2 := copy(sTemp, 1, c - 1) + Replace + copy(sTemp,c+1,C+Length(sTemp));
sTemp := sTemp2;
c := pos(Find, sTemp);
End;
Result := sTemp;
End;
Procedure TForm1.FormCreate(Sender: TObject);
Var s:string;
Eegin
s:='hej.hej.hej';
showmessage(form1.Replace(s,'.',','));
End;
End.