delphi tstringlist indexof find 查找字符串


本文整理自网络,侵删。

 
Find是折半查找 速度应该是最快了而indexof默认是 for 循环所有item了。 但find使用前必须先排序 sort 否则返回 index错误。

示例如下:

var  lst:TStringList ;
     i:Integer ;
begin
 
  lst:=TStringList.Create ;
 
  try
 
    lst:=TStringList.Create ;
    lst.CaseSensitive :=true;
    lst.Delimiter :=',';
    lst.DelimitedText :=Edit1.Text ;
 
    ShowMessage(IntToStr(lst.IndexOf(Edit2.Text) ));
    lst.Sort ;
        if lst.Find(Edit2.Text ,i) then
      ShowMessage(IntToStr(i));
  finally
 
    lst.Free ;
  end;
eidt2 内容 如下字符串  010a,010A,200a,200b,905a

来源:https://www.cnblogs.com/chinawcs/archive/2011/09/21/2184104.html

相关阅读 >>

Delphi idhttp 实战用法(tidhttpex)

Delphi xe6 android 查看电池信息

Delphi 用 directshow 获取本机的视频摄像设备列表

Delphi 简单电池电量显示

Delphi searchrec.attr and fadirectory

Delphi 设置本地系统时间

Delphi xe安装后配置android的sdk的方法

Delphi bytestofile

Delphi 利用createservice写与桌面交互的win32服务

Delphi 使用firedac打开sqlite数据库韩文、阿拉伯文出现乱码的处理方法

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



打赏

取消

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

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

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

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

评论

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