Welcome

首页 / 软件开发 / Delphi / Delphi中优秀的字符串分割函数

Delphi中优秀的字符串分割函数2011-12-15 csdn博客 mahuziDelphi没有自己的字符串分割函数,所以只能程序员自己写了,网上搜了好多但是真正好用的没有几个。

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

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;