--- title: "lastIndexOf" description: "Searches for the last occurrence of the substring inside of string." --- # lastIndexOf > Searches for the last occurrence of the substring inside of string. **This function is used by Ignition's Expression language.** ## Description 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. ## Syntax `lastIndexOf(string, substring)` ### Parameters | Type | Parameter | Description | |------------------|-------------|--------------------------------------------------------------------------------------------------| | String or List | `string` | The string to search through. As of version 8.1.8, this parameter also accepts tuples and lists. | | String | `substring` | The string to search for. | ### Returns **Integer** - The index where the substring was last found in the string. Returns -1 if the substring is not found. ## Examples ```py title="Code Snippet" lastIndexOf("Hamburger", "urge") //Returns 4. ``` ```py title="Code Snippet" lastIndexOf("Test", "") //Returns 4. ``` ```py title="Code Snippet" lastIndexOf("Dysfunctional", "fun") //Returns 3. ``` ```py title="Code Snippet" lastIndexOf("Dysfunctional", "marble") //Returns -1. ``` ```py title="Code Snippet" lastIndexOf("banana", "n") //Returns 4. ```