var
sl :TStringList;
s :string;
i :Integer;
begin
s := '0,1,2,3,4,5,6,7,8,9,10,11,';
s := StringReplace(s, ',', ',', [rfReplaceAll]);
sl := TStringList.Create;
try
sl.DelimitedText := s;
for i := 0 to sl.Count - 1 do
begin
s := Trim(sl.Strings[i]);
if s <> '' then
ShowMessage(s);
end;
finally
FreeAndNil(sl);
end;
end;
直接将其中的 逗号 替换就可以了吧?截取是什么意思
以下是替换的示例代码:
procedure TForm1.Button1Click(Sender: TObject);
var s: string;
begin
s := '0,1,2,3,4,5,6,7,8,9,10,11,';
ShowMessage(StringReplace(s,',',' ',[rfReplaceAll]));
end;
stringreplace(s,',',' '.[])