- 人气:
- 放大
- 缩小
- 二维码
- 赞赏
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