index
To return the first position of appearance of the match in the string
With this function, you can determine the position of a searched string within a given text. The search string can be a single character or a longer string.
Unlike
contains()
, this function not only checks whether the searched string exists but also determines the numeric value of its start position within the text. Counting starts at 0. Only if the searched string exactly matches the existing text, the position will be returned.
If the searched string is not found, the result is -1.
If the searched match is an empty string, the result will be 0.
index(string, string)
number
index(string, match)
Determines the first position of a given match in a given string, starting with 0.index("Ninox is great!", "ox")
Result: 3
index("Ninox is great!", "N")
Result: 0
index("Ninox is great!", "oX")
Result: -1 (no exact match found)
Last modified 1yr ago