Substring.LastIndexOfAny Method

Overload List

#SignatureDescription
1function LastIndexOfAny(const AnyOf: array of Char): Integer; overload;The 0-based index of the last character that is one of AnyOf, in the text, in [0, StartIndex], or in the Count characters that end at StartIndex.
2function LastIndexOfAny(const AnyOf: array of Char; const StartIndex: Integer): Integer; overload;
3function LastIndexOfAny(const AnyOf: array of Char; const StartIndex, Count: Integer): Integer; overload;

Overload 1: function LastIndexOfAny(const AnyOf: array of Char): Integer; overload;

The 0-based index of the last character that is one of AnyOf, in the text, in [0, StartIndex], or in the Count characters that end at StartIndex.

#NameTypeDescription
1AnyOfarray of Char

Returns: Integer - The index, or -1.

Remarks:

StartIndex = -1 with Count = 0 is an empty range; a range outside the text raises ESubstringRangeError.

Examples

The last separator.

uses Substr;

procedure Example;
begin
    Assert(Substring('a=b;c').LastIndexOfAny(['=', ';']) = 3);
end;

Overload 2: function LastIndexOfAny(const AnyOf: array of Char; const StartIndex: Integer): Integer; overload;

#NameTypeDescription
1AnyOfarray of Char
2StartIndexInteger

Returns: Integer

Overload 3: function LastIndexOfAny(const AnyOf: array of Char; const StartIndex, Count: Integer): Integer; overload;

#NameTypeDescription
1AnyOfarray of Char
2StartIndexInteger
3CountInteger

Returns: Integer