String.IndexOfAny

Syntax

IndexOfAny(Value: String; [StartIndex: Integer = 0;] [Count: Integer = -1]): Integer;

Parameters

Value. The substring, which characters should be searched for in the string.

StartIndex. Index of the source string element, with which search should begin. By default, the search starts from the string beginning.

Count. The number of character places, within which the search is executed. By default, the search is executed within the entire string.

Description

The IndexOfAny method returns the index of the first occurrence of any of substring characters passed in the Value parameter in the current string.

Comments

If none of the characters of the specified substring is found in the source string, the method returns -1. Characters are case-sensitive.

Example

Sub UserProc;
Var
    s: String;
Begin
    s := "Prognoz";
    Debug.WriteLine(s.IndexOfAny("ab"));
    Debug.WriteLine(s.IndexOfAny("ao"));
    Debug.WriteLine(s.IndexOfAny("ab"3));
    Debug.WriteLine(s.IndexOfAny("ao"33));
End Sub UserProc;

After executing the example the development environment console displays the following values:

-1

2

-1

5

See also:

String