LASTINDEXOF function

Synopsis
This function searches a string and returns the index of the first character of the last occurrence of the specified string.
Variations
LASTINDEXOF(SearchedString, SearchString)
Seaches a string and returns the index of the last 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, the size of String 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 the last occurrence of the string "Matrox" and returns 30.

LASTINDEXOF("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 40.

LASTINDEXOF("Matrox Design Assistant with Matrox Iris", "")}
3.

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

LASTINDEXOF("Matrox Design Assistant with Matrox Iris", "MATROX")
LASTINDEXOF(SearchedString, SearchString, StartIndex)
Seaches a string beginning at the specified character index and proceeding in a backwards direction. 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" working backwords from index 20 for "Matrox" and returns 1.

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

The following example searches the string "Matrox Design Assistant with Matrox Iris" working backwords from index 35 for "Matrox" and returns 30.

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

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

LASTINDEXOF("Matrox Design Assistant with Matrox Iris", "", 20)
LASTINDEXOF(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 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 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 "Matrox" beginning at index 15 working backwords to index 5. This example returns 0.

LASTINDEXOF("Matrox Design Assistant with Matrox Iris", "Matrox", 15, 10)
2.

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

LASTINDEXOF("Matrox Design Assistant with Matrox Iris", "Matrox", 15, 15)
3.

The following example searches the string "Matrox Design Assistant with Matrox Iris" for "Matrox" beginning at index 36 and working backwords to index 21. This example returns 30.

LASTINDEXOF("Matrox Design Assistant with Matrox Iris", "Matrox", 36, 15)
4.

The following example searches the string "Matrox Design Assistant with Matrox Iris" for "Matrox" beginning at index 36 and working backwords to index 31 This example returns 0.

LASTINDEXOF("Matrox Design Assistant with Matrox Iris", "Matrox", 36, 5)