Policies & Guidelines

SELECT_BY_REGEX

Find objects from array by a key-regex match

Description

Finds multiple objects from the given array by a key-regex pair.

For example, given Key "name" and Pattern /Agnus/, will return an array containing all objects in the array whose name property contains Agnus, or an empty array if no matching objects were found.

Function signature

SELECT_BY_REGEX(array: Array, key: String, pattern: String) => Array

Parameter

Description

Array

Array to find objects in

Key

Key whose value to match

Pattern

Regex pattern to match

Examples

array1 = [{"a":2},{"a":"foo bar"},{"a":"foo","b":3}]

Formula

Return value

SELECT_BY_REGEX(array1, "a", "^foo")

[{"a":"foo bar"},{"a":"foo","b":3}]

SELECT_BY_REGEX(array1, "a", "^foo")

[{"a":"foo bar"},{"a":"foo","b":3}]