Delphi中優(yōu)秀的字符串分割函數(shù)

字號:

Delphi沒有自己的字符串分割函數(shù),所以只能程序員自己寫了,網(wǎng)上搜了好多但是真正好用的沒有幾個。
    下面這個是我在網(wǎng)上找到修改后了的,個人感覺算法不錯,所以就貼了上來。
    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;