splitStr分割字符串函数

把source字符串按ch子串进行分割保存至stringlist中

function splitStr(ch:string;source:string):TStringList;
var i:Integer;
begin
  Result:=TStringList.Create;
  if (ch<>'')and (source<>'') then
  begin
    while pos(ch,source)>0 do
    begin
      i:=pos(ch,source);
      Result.Add(Copy(source,1,i-1));
      source:=Copy(source,i+ Length(ch),Length(source));
    end;
    Result.Add(source);
  end;
end;

 

 

posted @ 2013-05-29 14:23  胖达没有海  阅读(1143)  评论(0编辑  收藏  举报