delphi LastDelimiter:在字符串中查找选定的字符最后出现的位置  
官方Delphi 学习QQ群: 682628230(三千人)
频道

delphi LastDelimiter:在字符串中查找选定的字符最后出现的位置


//SysUtils.LastDelimiter 

声明:function LastDelimiter ( const Delimiters, Source : string ) : Integer;
描述:LastDelimiter函数查找在Source字符串中Delimiter集合中任一字符最后出现的位置。
如果找到,则返回位置值,否则,返回0。
备注:字符串第一个字符开始于1。

var   
source, find : string;   
position : Integer;  
begin   // 创建一个字符串   
source := '12345678901234567890';    // 查找最后一个“1”的位置  
position := LastDelimiter('1', source);   
ShowMessage('The last 1 is at '+IntToStr(position));    // 查找2,4或6最后出现的位置   
position := LastDelimiter('246', source);   
ShowMessage('The last 2, 4 or 6 is at '+IntToStr(position)); 
end;
程序运行结果:

The last 1 is at 11

The last 2, 4 or 6 is at 16

推荐分享
图文皆来源于网络,内容仅做公益性分享,版权归原作者所有,如有侵权请告知删除!
 

Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号

执行时间: 0.041962862014771 seconds