FIND
- FIND(match_string, search_string, start_index=None)[source]
Returns the starting position of a substring within a string.
This function mimics the behavior of the Excel FIND function. It searches for the first occurrence of match_string within search_string and returns the 1-based starting position. An optional start_index argument can be provided to begin the search from a specific position in the string. If any argument is blank or in an error state, the formula evaluates to an error.
FIND does have array support, meaning any of the arguments can be arrays and the output will also be an array. If multiple arguments are arrays, they must be of the same length, else the formula will evaluate to an error.
- Parameters:
match_string (
Operand|str) –The substring to search for within search_string. If blank or in an error state, the formula evaluates to an error.
Supported types:
STRING
STRING_ARRAY
search_string (
Operand|str) –The string within which to search for match_string. Must be a valid string or string array. If blank or in an error state, the formula evaluates to an error.
Supported types:
STRING
STRING_ARRAY
start_index (
Operand|int|None) –Optional. The 1-based position to start searching from. Defaults to 1 if not provided.
Supported types:
INTEGER
INTEGER_ARRAY
- Return type:
- Returns:
Returns the index within this string of the first occurrence of the specified substring, starting at start_index if specified, otherwise 1. If the substring is not found, the formula evaluates to 0.
Supported types:
INTEGER
INTEGER_ARRAY
- Raises:
ValueError – if match_string or search_string is not of type STRING or STRING_ARRAY.
ValueError – if start_index is not of type INTEGER or INTEGER_ARRAY.
Examples
Basic usage:
FIND("apple", "apple pie") # Returns 1
Starting from a specific index:
FIND("apple", "banana apple pie", start_index=5) # Returns 8