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;
原文地址:https://www.cnblogs.com/hejoy91/p/3105913.html