- search in the string to search in
- find is the string you're trying to find
- start is the (optional) starting position
This function searches through the string search, looking for the string find. If the optional parameter start is specified, it will start searching from that position inside of search, ignoring everything that comes before start in search. This function returns the position where find first occurs in search, or -1 if find was not found. This function returns a 0-indexed value, meaning that the first character of search counts as 0. Note that the return value is still based on the full string search if start is specified; it simply ignores any matches made before that point.
Searches for the letter "c" in the lowercase alphabet.Would result in:
Searches for "Bob" in a line of text, ignoring the first 3 characters.Would result in:
If find does not occur in search (or the portion searched, when start is specified), this function returns -1.