Delphi Split 方法使用


本文整理自网络,侵删。

 
procedure Split(const Text: string; Delimiter: Char; List: TStrings);
var Start, Index: Integer;
begin
  List.BeginUpdate;
  try
    Start := 1;
    for Index := 1 to Length(Text) do
      if Text[Index] = Delimiter then
      begin
        List.Add(Copy(Text, Start, Index - Start));
        Start := Index + 1;
      end;

    if Start <= Length(Text) then
      List.Add(Copy(Text, Start, Length(Text) - Start + 1));
  finally
    List.EndUpdate;
  end
end;



procedure TForm1.Button1Click(Sender: TObject);
begin
Split('123,456,789',',',Memo1.Lines);
Split('111,222,333',',',Memo1.Lines);
end;

相关阅读 >>

Delphi 获取internet缓存文件

Delphi 计算程序运行时间

Delphi-idhttp-json用法

Delphi 中的包开发

Delphi xe7检查android蓝牙权限

Delphi 程序动态改变皮肤

Delphi 获取系统托盘程序列表

Delphi下载官方svn中的示例原码

Delphi中的进制转换

Delphi之数组

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...

    正在狠努力加载,请稍候...