FIND
Returns the position in the specified string of a substring, starting at the specified start position.
Syntax
=FIND(needle, haystack, start)
Arguments
Argument | Type | Description |
---|---|---|
needle | String | The string to find |
haystack | String | The string to search in |
start | Number | (Optional) The index in the haystack to start searching. Defaults to 1 |
Start is 1-based (i.e. an index of 1 is used for the first character). Negative indexes are allowed and index from the end of the string (i.e. an index of -1 gets the last character).
Examples
=FIND("ABC", "ABCDEF")
→1
Finds the string "ABC" in the string "ABCDEF" (starting at character 1, because the index was not specified). Since the string starts with "ABC", returns 1
=FIND("ABC", "ABCDEF", 2)
→None
Finds the string "ABC" in the string "ABCDEF" starting at character 2. The string "ABC" is not found starting at character 2, because the find function is searching within "BCDEF"
=FIND("XYZ", "ABCDEF")
→None
Finds the string "XYZ" in the string "ABCDEF" (starting at character 1, because the index was not specified). The string "XYZ" is not found in the string, so this returns None
=FIND("X","XXXXXX")
→1
Finds the string "X" in the string "XXXXXX" (starting at character 1, because the index was not specified). The string "X" is found multiple times in the string, so the first match is returned (1)
=FIND("Z","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
→26
Finds the string "Z" in the string "ABCDEFGHIJKLMNOPQRSTUVWXYZ" (starting at character 1, because the index was not specified)
=FIND("Y", "XYZXYZ", -3)
→4
Finds the string "Y" in the string "XYZXYZ" starting at the 3rd character from the end
Updated 8 months ago