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 调用sql和mysql存储过程

Delphi2010中使用pchar时e2010 incompatible types: 'char' and 'ansichar' 错误的处理

Delphi程序将自身可执行文件拷贝到u盘的代码

Delphi实现票据精确打印

unigui js操作Delphi控件赋值

Delphi windows 编程[11] - wm_size 消息

Delphi 闪盘小偷

Delphi http post json示例

Delphi 获取进程列表及相关信息

Delphi 支持通配符删除文件

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



打赏

取消

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

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

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

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

评论

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

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