INDEXOF function

Synopsis
This function searches a string and returns the index of the first character of the first occurrence of the specified string.
Variations
INDEXOF(SearchedString, SearchString)
Seaches a string and returns the index of the first occurrence of the specified string. Returns 0 if the string was not found.
Parameters
SearchedString

Specifies the string to be searched.

Supported types: String.
SearchString

Specifies the string for which to search. When SearchString is empty, 1 is returned. If SearchString is 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 "Matrox" and returns 1.

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

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

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

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

INDEXOF("Matrox Design Assistant with Matrox Iris", "MATROX")
INDEXOF(SearchedString, SearchString, StartIndex)
Seaches a string beginning at the specified character index. Returns the index of the first occurrence of the specified string within the specified limits. Returns 0 if the string was not found.
Parameters
SearchedString

Specifies the string to be searched.

Supported types: String.
SearchString

Specifies the string for which to search. When SearchString is empty, StartIndex is returned. If SearchString is 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 "Matrox" and returns 30.

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

The following example searches the string "Matrox Design Assistant with Matrox Iris" beginning at index 35 for "Matrox" and returns 0.

INDEXOF("Matrox Design Assistant with Matrox Iris", "Matrox", 35)
3.

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

INDEXOF("Matrox Design Assistant with Matrox Iris", "", 20)
INDEXOF(SearchedString, SearchString, StartIndex, CharNum)
Seaches a string beginning at the specified character index and ending after a specified number of characters. Returns the index of the first occurrence of the specified string within the specified limits. Returns 0 if the string was not found.
Parameters
SearchedString

Specifies the string to be searched.

Supported types: String.
SearchString

Specifies the string for which to search. When SearchString is empty, StartIndex is returned. If SearchString is 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 characters 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 "Matrox" beginning at index 1 and ending at index 5. This example returns 0.

INDEXOF("Matrox Design Assistant with Matrox Iris", "Matrox", 1, 5)
2.

The following example searches the string "Matrox Design Assistant with Matrox Iris" for "Matrox" beginning at index 1 and ending at index 6. This example returns 1.

INDEXOF("Matrox Design Assistant with Matrox Iris", "Matrox", 1, 6)
3.

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

INDEXOF("Matrox Design Assistant with Matrox Iris", "Matrox", 20, 15)
4.

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

INDEXOF("Matrox Design Assistant with Matrox Iris", "Matrox", 20, 14)