Delphi中优秀的字符串分割函数

来源:岁月联盟 编辑:exp 时间:2009-05-01

DELPHI没有自己的字符串分割函数,所以只能程序员自己写了,网上搜了好多但是真正好用的没有几个,

下面这个是我在网上找到修改后了的,个人感觉算法不错,所以就贴了上来。

 

function SplitString(Source, Deli: string ): TStringList;stdcall;            var            EndOfCurrentString: byte;            StringList:TStringList;            begin            StringList:=TStringList.Create;            while Pos(Deli, Source)>0 do            begin            EndOfCurrentString := Pos(Deli, Source);            StringList.add(Copy(Source, 1, EndOfCurrentString - 1));            Source := Copy(Source, EndOfCurrentString + length(Deli), length(Source) - EndOfCurrentString);            end;            Result := StringList;            StringList.Add(source);            end;

图片内容