Delphi 搜索字符串


本文整理自网络,侵删。

 
搜索字符串:

//--------------------------------------------------------------------------------
var
  str: string;
  n: Integer;
begin
  str := 'A1 A2 A3 A4';

  n := str.IndexOf('A');     // 0
  n := str.LastIndexOf('A'); // 9
  n := str.IndexOf('B');     // -1; 没找到

  n := str.IndexOf('A', 1, str.Length - 1);                  // 3
  n := str.LastIndexOf('A', str.Length - 1, str.Length - 1); // 9

  n := str.IndexOfAny(['1', '2', '3', '4']);     // 1
  n := str.LastIndexOfAny(['1', '2', '3', '4']); // 10
end;

相关阅读 >>

Delphi fmx 安卓跳转到支付宝付款页面

Delphi mediaplayer1 设置音量

Delphi结构,字符串和指针

Delphi整理三(窗体和基本组件)

Delphi tadodataset 中文使用说明

Delphi mscomm简单的中间pc串口数据中转

Delphi对cookie的操作

Delphi 根据经纬度计算地球上两点之间的距离

Delphi 双击richedit高亮所有关键字

Delphi的rtti实现数据集的简单对象化

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



打赏

取消

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

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

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

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

评论

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