delphi中怎样替换整个项目中的某个字符串
1个回答
展开全部
function replace(s,sa,sb:string):string;
var
i,k:integer;
temp:string;
begin
k:=length(sa);
i:=pos(sa,s);
temp:=s;
if i<>0 then begin
temp:=copy(s,1,i-1)+sb+copy(s,i+k,length(s)-i-k+1);
end;
replace:=temp;
end;
begin
writeln(replace('1234AA5678','AA','pppp'));
end.
var
i,k:integer;
temp:string;
begin
k:=length(sa);
i:=pos(sa,s);
temp:=s;
if i<>0 then begin
temp:=copy(s,1,i-1)+sb+copy(s,i+k,length(s)-i-k+1);
end;
replace:=temp;
end;
begin
writeln(replace('1234AA5678','AA','pppp'));
end.
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询