indexOf

indexOf(string string, string search, [number start]) → integer index
Finds the first occurrence of search string within given string, starting at position start.

Finds the position of the first occurrence of the string search in the string string.

Parameters
Return
Python

In Python, s.find(search) returns -1 when the pattern is absent, exactly like indexOf in LeekScript; it is s.index(search) that raises a ValueError. In both cases, the second argument is the starting index: "hello".find("l", 3) is 3. Lists have no find: only a.index(value) is available, and it raises an error when the value is absent — see search.

Examples

indexOf("Bonjour", "jour") // 3 indexOf("Bonjour", "zzz") // -1 indexOf("Bonjour tout le monde", "on", 0) // 1 indexOf("Bonjour tout le monde", "on", 10) // 17