当前位置:首页>>网络编程>>Delphi教程>>正文

delphi中的split函数

文章出处:网络转载 作者:未知 发布时间:2006-07-28 收藏到QQ书签

//根据字符串,拆分字符串,相当于vb中的split函数
function SplitString(const Source,ch:string):TStringList;
var
  temp:String;
  i:Integer;
begin
  Result:=TStringList.Create;
  //如果是空自符串则返回空列表
  if Source=''
  then exit;
  temp:=Source;
  i:=pos(ch,Source);
  while i<>0 do
  begin
     Result.add(copy(temp,0,i-1));
     Delete(temp,1,i);
     i:=pos(ch,temp);
  end;
  Result.add(temp);
end;

www.sinoprise.com


Google