LASTINDEXOFANY function

Synopsis
This function searches a string and returns the index of the last occurrence of any character in the specified string.
Variations
LASTINDEXOFANY(SearchedString, SearchString)
Seaches a string and returns the index of the last occurrence of any character in the specified string. Returns 0 if no characters were found.
Parameters
SearchedString

Specifies the string to be searched.

Supported types: String.
SearchString

Specifies the characters for which to search. If no characters in SearchString are 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 last occurrance of any characters in the string "Matrox" and returns 38.

LASTINDEXOFANY("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 0.

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

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

LASTINDEXOFANY("Matrox Design Assistant with Matrox Iris", "ROX")
LASTINDEXOFANY(SearchedString, SearchString, StartIndex)
Seaches a string beginning at the specified character index and proceeding in a backwards direction. Returns the index of the last occurrence of any character in the specified string within the specified limits. Returns 0 if no characters were found.
Parameters
SearchedString

Specifies the string to be searched.

Supported types: String.
SearchString

Specifies the characters for which to search. If no characters in SearchString are 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", working backwords from index 20, for the characters in the string "Iris" and returns 19.

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

The following example searches the string "Matrox Design Assistant with Matrox Iris", working backwords from index 20, for an empty string and returns 0.

LASTINDEXOFANY("Matrox Design Assistant with Matrox Iris", "", 20)
LASTINDEXOFANY(SearchedString, SearchString, StartIndex, CharNum)
Seaches a string beginning at the specified character index and ending after a specified number of characters while searching in a backwards direction. Returns the index of the last occurrence of the specified string within the specified limits. Returns 0 if no characters were found.
Parameters
SearchedString

Specifies the string to be searched.

Supported types: String.
SearchString

Specifies the characters for which to search. If no characters in SearchString are 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 in a reverse direction 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 working backwords to index 7. This example returns 0.

LASTINDEXOFANY("Matrox Design Assistant with Matrox Iris", "Matrox", 15, 9)
2.

The following example searches the string "Matrox Design Assistant with Matrox Iris" for the characters in the string "Matrox", beginning at index 15 and working backwords to index 6. This example returns 6.

LASTINDEXOFANY("Matrox Design Assistant with Matrox Iris", "Matrox", 15, 10)