INDEX_OF

Description

INDEX_OF returns the zero-based index of the first occurrence of a value in a list or string. If the value is not found, it returns -1.

Syntax

INDEX_OF(collection, value)

Returns: An integer index, or -1 if not found.

Example with a list

INDEX_OF(['red', 'green', 'blue'], 'green')

This returns 1, since 'green' is at index 1 (zero-based).

Example with a string

INDEX_OF('Hello World', 'World')

This returns 6, the position where 'World' begins.

Example when not found

INDEX_OF(['a', 'b', 'c'], 'z')

This returns -1.

Last updated

Was this helpful?