Searches for the last occurrence of the substring inside of string. Returns the index of where substring was found, or -1 if it wasn't found. The first position in the string is position 0.

lastIndexOf(string, substring)

  • Parameters

String, Tuple, or List object - The object to search through.

The string parameter now accepts tuples and lists. 

String substring - The string to search for.

  • Results

String - The index where the substring was last found in the string.

lastIndexOf("Hamburger", "urge") //Returns 4.

lastIndexOf("Test", "") //Returns 4.

lastIndexOf("Dysfunctional", "fun") //Returns 3.

lastIndexOf("Dysfunctional", "marble") //Returns -1.

lastIndexOf("banana", "n") //Returns 4.