var
Str,s1: strings1:=copy(Str,length(Str)-4,4);
if s1='/100' then
begin
Str:=Copy(Str,1,length(Str)-4);
Str:=Str+'%';
end;
Str,s1: strings1:=copy(Str,length(Str)-4,4);
if s1='/100' then
begin
Str:=Copy(Str,1,length(Str)-4);
Str:=Str+'%';
end;
str,substr:string;
i:integer;
begin
str:='(A+B)*5/100....'
substr:='5/100';
i:=pos(substr,sub);
while i>0 do
begin
str:=copy(str,1,i-1)+'5/%'+copy(str,i+5,length(str)-(i+5)+1);
i:=pos(substr,sub);
end;
end;
var
str,substr:string;
i:integer;
begin
str:='(A+B)*5/100....'
substr:='/100';
i:=pos(substr,sub);
while i>0 do
begin
str:=copy(str,1,i-1)+'/%'+copy(str,i+4,length(str)-(i+4)+1);
i:=pos(substr,sub);
end;
end;
Str,s1: string;
begin
s1:=copy(Str,length(Str)-3,4);
if s1='/100' then
begin
Str:=Copy(Str,1,length(Str)-4);
Str:=Str+'%';
end;
end;
str := StringReplace( str, '/100', '%' );
多谢!我又学会一个函数。开卷有意啊!!
不过好像还少一个参数,我提你补上:
str := StringReplace( str, '/100', '%',[rfReplaceAll] );