Substring.IndexOfAny Method

Overload List

#SignatureDescription
1function IndexOfAny(const AnyOf: array of Char; const StartIndex: Integer = 0): Integer; overload;The 0-based index of the first character that is one of AnyOf, from StartIndex to the end or for Count characters.
2function IndexOfAny(const AnyOf: array of Char; const StartIndex, Count: Integer): Integer; overload;

Overload 1: function IndexOfAny(const AnyOf: array of Char; const StartIndex: Integer = 0): Integer; overload;

The 0-based index of the first character that is one of AnyOf, from StartIndex to the end or for Count characters.

#NameTypeDescription
1AnyOfarray of Char
2StartIndexInteger

Returns: Integer - The index, or -1.

Remarks:

A range outside the text raises ESubstringRangeError.

Examples

The first separator.

uses Substr;

procedure Example;
var s: Substring;
begin
    s := Substring('a=b;c');
    Assert(s.IndexOfAny(['=', ';']) = 1);
    Assert(s.IndexOfAny(['=', ';'], 2) = 3);
end;

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

#NameTypeDescription
1AnyOfarray of Char
2StartIndexInteger
3CountInteger

Returns: Integer