--- title: "indexOf" description: "Searches for the first occurrence of the substring inside of string." --- # indexOf > Searches for the first occurrence of the substring inside of string. **This function is used by Ignition's Expression language.** ## Description Searches for the first 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 `indexOf(string, substring)` - Parameters - string **string** - The string to search through. - string **substring** - The string to search for. - Results - string - The index where the substring was first found in the string. ## Examples ```python title="Code Snippet" indexOf("Hamburger", "urge") //returns 4 ``` ```python title="Code Snippet" indexOf("Test", "") //returns 0 ``` ```python title="Code Snippet" indexOf("Dysfunctional", "fun") //returns 3 ``` ```python title="Code Snippet" indexOf("Dysfunctional", "marble") //returns -1 ``` ```python title="Code Snippet" indexOf("banana", "n") //returns 2 ```