stringIndexOf
Modified on Wed, 02 Aug 2023
Description
Return the index of the first occurrence of the specified substring at a position greater than or equal to position, which defaults to 0.
Syntax
stringIndexOf(input, find, position)
Parameters
Input Parameter | Type | Description |
---|---|---|
input | string | The input string to search. |
find | string | The search string |
position (optional) | number | Start position which is optional. |
Return value
Type |
---|
number |
Sample
Example | Result | Description |
---|---|---|
stringIndexOf('dog, cat, cat', 'cat') | 5 | Finds the first matched substring index |
stringIndexOf('dog, cat, dog', 'lion') | -1 | Return -1 if there is no match |
stringIndexOf('dog, cat, dog', 'dog', 5) | 10 | Return first matched substring index with given start position |
To view all the String functions, click here.
See Also
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article