用copy要好些,可以实现多字符替换多字符:
function replace(OldStr,NewStr,str:string):string;
var
i:integer;
begin
while str<>'' do
begin
i:=Pos(oldstr, Str);
if i=0 then
begin
Result:=Result+str;
Break;
end;
Result:=Result+Copy(Str,1,i-1)+NewStr;
Str:=Copy(Str,i+Length(Oldstr),length(str));
end;
end;