type
vartype = array of string;
TForm1 = class(TForm)
BitBtn2: TBitBtn;
procedure BitBtn2Click(Sender: TObject);
public
function split(S, delimeter: string): vartype;
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
var
bb: vartype;
i: integer;
begin
bb := split(' delphi,is,good ',',');
for i := low(bb) to high(bb) do
showmessage(bb);
end;
function TForm1.split(S, delimeter: string): vartype;
var
aa: vartype;
i, l: integer;
begin
l := 0;
setlength(aa,1);
while pos(delimeter,s) > 0 do
begin
i := pos(delimeter,s);
aa[high(aa)] := copy(s,l,i-1);
s := copy(s,i+1,length(s));
setlength(aa,length(aa)+1);
end;
aa[high(aa)] := s;
result := aa;
end;