無名经验总结与分享(SAP)            十年树木,百年树人

delphi 中 的 Split 函数

//根据字符串,拆分字符串,相当于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;

posted @ 2008-01-11 08:27  無名  阅读(517)  评论(0编辑  收藏  举报
Twttafku@163.com
十年树木,百年树人