字符串分割
procedure TForm1.Button1Click(Sender: TObject);
var tmpstr:string;
sl:tstringlist;
begin
tmpstr:='20*30*40*50' ;
sl :=
TStringList.Create;
try
sl.Add(tmpstr);
sl.Delimiter:='*';
sl.DelimitedText:=sl.Text ;
listbox1.Items:=sl;
self.Caption:=sl.Strings[2];
finally
sl.Free;
end;
end;
//分割字符串 ExtractStrings var s: String; List: TStringList; begin s := 'about: #delphi; #pascal, programming'; List := TStringList.Create; ExtractStrings([';',',',':'],['#',' '],PChar(s),List); //第一个参数是分隔符; 第二个参数是开头被忽略的字符 ShowMessage(List.Text); //about //delphi //pascal //programming List.Free;