function SplitStr(Source:String;ch:string):TStringList;
var
temp:String;
i:Integer;
begin
Result := TStringList.Create;
if Source='' then exit;
temp:=Source;
i:=pos(ch,Source);
if i > 0 then
begin
while i<> 0 do
begin
Result.add(copy(temp,0,i-1));
Delete(temp,1,i);
i:=pos(ch,temp);
end;
end;
Result.add(temp);
end;
----------------------------
调用:
var
vTs:TStrings;
begin
vTs:=SplitStr('abc,d e f,ghi',',');
end;
var
temp:String;
i:Integer;
begin
Result := TStringList.Create;
if Source='' then exit;
temp:=Source;
i:=pos(ch,Source);
if i > 0 then
begin
while i<> 0 do
begin
Result.add(copy(temp,0,i-1));
Delete(temp,1,i);
i:=pos(ch,temp);
end;
end;
Result.add(temp);
end;
----------------------------
调用:
var
vTs:TStrings;
begin
vTs:=SplitStr('abc,d e f,ghi',',');
end;