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

 

附:delphi的字符截取函数LeftStr, MidStr, RightStr拆分字符串

http://ccfengshuo.blog.sohu.com/74622338.html

posted @ 2014-04-24 10:05  stma  阅读(377)  评论(0)    收藏  举报