Delphi SplitString 字符串分割成字符串组

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;

  Result := StringList;

  StringList.Add(Source);

end;

procedure TForm1.FormCreate(Sender: TObject);

begin

Caption:=SplitString('123==456==789','==').Strings[1];

end;

你可能感兴趣的:(Delphi,delphi,pascal)