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 弹出输入框的inputquery, inputquery 函数用法

Delphi编写系统服务

Delphi indy 10tidftp中的directorylisting使用

Delphi中time消息的使用方法

Delphi 基础学习 字符串去掉回车符

Delphi idhttp实现地址自动转向

Delphi 读写附加数据

Delphi xe5 android实现繁体字到简体字的转换函数

Delphi 高速替换大文本字符串内容

Delphi 如何读取内存中的数据?

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



打赏

取消

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

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

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

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

评论

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