INDEX_OF

Returns the index of the specified term within the provided string or array. With arrays you can provide a LAMBDA as the second argument, and the index of the first matching result it returned.

Syntax 

INDEX_OF(string_or_array, object | LAMBDA(value, expr)

Usage examples 

Example 1

Input

1
{
2
"my_action": {
3
"data": [
4
"foo",
5
"bar"
6
]
7
}
8
}

Formula

INDEX_OF(my_action.data, "foo")

Output

0

Example 2

Input

1
{
2
"my_action": {
3
"string": "foobar"
4
}
5
}

Formula

INDEX_OF(my_action.string, "bar")

Output

3

Example 3

Input

1
{
2
"my_action": {
3
"data": [
4
"foo",
5
"bar"
6
]
7
}
8
}

Formula

INDEX_OF(my_action.data, "cat")

Output

null

Example 4

Use LAMBDA with arrays to return the index of the first matching value

Input

1
{
2
"my_action": {
3
"data": [
4
1,
5
2,
6
3,
7
4,
8
5
9
]
10
}
11
}

Formula

INDEX_OF(my_action.data, LAMBDA(value, value > 2)

Output

2
Was this helpful?