Policies & Guidelines

FIND_BY_REGEX

Find an object in array by matching a key value with a regex pattern

Description

Finds an object in the given array by comparing the value of each object's Key property with the given regex.

For example, given Key "name" and Value Agnus, will return the object in the array whose name property contains Agnus, or null if such an object was not found.

If multiple matches exist, the first matching object is returned.

Function signature

FIND_BY_REGEX(array: Array, key: String, pattern: String) => Object

Parameter

Description

Array

Array to find object in

Key

Key whose value to match

Pattern

Regex pattern to match

Examples

array = [{"a":"abar"},{"a":"bar"},{"a":"foo bar"},{"a":1}]

Formula

Return value

FIND_BY_REGEX(array, "a", "^foo")

{"a":"foo bar"}