position(haystack: string, needle: string, [start: int64]?) -> int64

Searches for the first occurrence of the second argument (needle) in the first argument (haystack).

If successful, returns the needle's position (0-based). Returns -1 if the needle is not found.

Domain

This is a scalar function (calculates a single output value for a single input row).

Categories

Examples

make_col p:position('fuzzy wuzzy', 'uzzy', 5)

Looks for the first occurrence of the needle 'uzzy' starting at index 5 (0-based) in the haystack 'fuzzy wuzzy'. Returns 7.