I made this function tonight and thought it'd be usefull to share. Not that it's hard to code, but just something to share (and get feedback on how to make faster )

This function is to find and replace all instances of a substring in a string.

[pascal]function Replace(FindStr, ReplaceWith, Source : String) : String;
var i,c : integer;
begin
c := Length(FindStr);
i := Pos(FindStr, Source);
while i <> 0 do
begin
Source := Copy(Source, 1, i - 1) + ReplaceWith + Copy(Source, i + c, Length(Source));
i := Pos(FindStr, Source);
end;
Result := Source;
end;[/pascal]