现在的位置: 首页 > 综合 > 正文

delphi中的split函数

2013年09月22日 ⁄ 综合 ⁄ 共 351字 ⁄ 字号 评论关闭
 

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

抱歉!评论已关闭.