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