unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject);//分割 var s: String; List: TStringList; begin s := 'about: #delphi; #pascal, programming'; List := TStringList.Create; ExtractStrings([';',',',':'],['#',' '],PChar(s),List);//第一个参数是分隔符; 第二个参数是开头被忽略的字符 ShowMessage(List.Text); List.Free; end; procedure TForm1.FormCreate(Sender: TObject);//应用程序初始化 begin Form1.Caption:='分割字符串'; Button1.Caption:='分割'; end; end.
关于TStringList类请参考http://www.cnblogs.com/keycode/archive/2010/10/25/1860436.html