INDEXOFANY function

Synopsis
This function searches a string and returns the index of the first occurrence of any character in the specified string.
Variations
INDEXOFANY(SearchedString, SearchString)
Searches a string and returns the index of the first occurrence of any character from a specified string.
Parameters
SearchedString

Specifies the string to be searched.

Supported types: String.
SearchString

Specifies the characters for which to search. When SearchString is empty, 1 is returned. If the SearchString characters are not found, 0 is returned.

Supported types: String.
Returns
Returned types: Numeric.
Examples
1.

The following example searches the string "Matrox Design Assistant with Matrox Iris" for the characters in the string "Iris" and returns 4.

INDEXOFANY("Matrox Design Assistant with Matrox Iris", "Iris")
2.

The following example searches the string "Matrox Design Assistant with Matrox Iris" for an empty string and returns 1.

INDEXOFANY("Matrox Design Assistant with Matrox Iris", "")
3.

The following example searches the string "Matrox Design Assistant with Matrox Iris" for the characters in the string "ROX" and returns 0.

INDEXOFANY("Matrox Design Assistant with Matrox Iris", "ROX")
INDEXOFANY(SearchedString, SearchString, StartIndex)
Searches a string beginning with the specified character index. Returns the index of the first occurrence of any character from a specified string.
Parameters
SearchedString

Specifies the string to be searched.

Supported types: String.
SearchString

Specifies the characters for which to search. When SearchString is empty, StartIndex is returned. If the SearchString characters are not found, 0 is returned.

Supported types: String.
StartIndex

Specifies the index at which to begin the search.

Supported types: Numeric.
Returns
Returned types: Numeric.
Examples
1.

The following example searches the string "Matrox Design Assistant with Matrox Iris" beginning at index 20 for the characters in the string "Iris" and returns 26.

INDEXOFANY("Matrox Design Assistant with Matrox Iris", "Iris", 20)
2.

The following example searches the string "Matrox Design Assistant with Matrox Iris" beginning at index 20 for an empty string and returns 20.

INDEXOFANY("Matrox Design Assistant with Matrox Iris", "", 20)
INDEXOFANY(SearchedString, SearchString, StartIndex, CharNum)
Searches a string beginning with the specified character index and ending after a specified number of characters. Returns the index of the first occurrence of any character from a specified string.
Parameters
SearchedString

Specifies the string to be searched.

Supported types: String.
SearchString

Specifies the characters for which to search. When SearchString is empty, StartIndex is returned. If the SearchString characters are not found, 0 is returned.

Supported types: String.
StartIndex

Specifies the index at which to begin the search.

Supported types: Numeric.
CharNum

Specifies the number of indices to be examined after StartIndex before ending the search.

Supported types: Numeric.
Returns
Returned types: Numeric.
Examples
1.

The following example searches the string "Matrox Design Assistant with Matrox Iris" for the characters in the string "Matrox" beginning at index 8 and ending at index 19. This example returns 0.

INDEXOFANY("Matrox Design Assistant with Matrox Iris", "Matrox", 8, 12)
2.

The following example searches the string "Matrox Design Assistant with Matrox Iris" for the characters in the string "Matrox" beginning at index 8 and ending at index 20. This example returns 20.

INDEXOFANY("Matrox Design Assistant with Matrox Iris", "Matrox", 8, 13)