Delphi-分割文本

function SplitString(Source, Deli: string): TStringList;
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;
  StringList.Add(Source);
  Result := StringList;
end;

猜你喜欢

转载自www.cnblogs.com/YiShen/p/9687750.html
今日推荐