- 人气:
- 放大
- 缩小
- 二维码
- 赞赏
delphi把一个字符串中的某个子串,用另一个子串去替换
DELPHI把一个字符串中的某个子串,用另一个子串去替换
function StrReplace(s,oldstr,newstr:string):string; //字符串替换
var
SelPos,SelLen: Integer;
begin
SelPos := Pos(oldstr, s);
while SelPos > 0 do
begin
SelLen := Length(oldstr);
delete(s,SelPos,SelLen);
insert(newstr,s,SelPos);
SelPos := Pos(oldstr, s);
end;
Result:=s;
end;