The REGEX_IN_ARRAY function is used to build a regular expression pattern from an array of values to perform a context filter operation. The resulting regex pattern is in the form /(VALUE1|VALUE2|...)/ig.

Usable: Context Filter

Syntax: { REGEX_IN_ARRAY(( PARAM_1 )) }

Parameter

Type

Example

Description

PARAM_1

JSONPath Array

$.user.groups.items[*].name

A list of values that will be used to build the regular expression pattern. Can be used to retrieve context values from $.issue.... or $.user....

Context Filter Example:

For example, consider the following data source JSON:

{
  "result": [
    {
      "id": 1,
      "group": "administrators",
      "name": "Mario Speedwagon",
      "username": "mario"
    },
    .... more items here ....
  ]
}
CODE

To filter results based on whether the current user’s groups matches one of the values in the JSON array, use the following expression:

$.result[?(@.group=~{ REGEX_IN_ARRAY(( $.user.groups.items[*].name )) })]
CODE

If $.user.groups.items[*].name contains administrators and jira-core-users the expression will resolve to the regular expression

$.result[?(@.group=~/(administrators|jira-core-users)/ig)]
CODE

Same but with an array of groups in you data source

{
  "result": [
    {
      "id": 1,
      "groups": ["administrators","jira-servicedesk-users"],
      "name": "Mario Speedwagon",
      "username": "mario"
    },
    .... more items here ....
  ]
}
CODE
$.result[?(@.group[?(@=~{ REGEX_IN_ARRAY(( $.user.groups.items[*].name )) })])]
CODE

If $.user.groups.items[*].name contains administrators and jira-core-users the expression will resolve to the regular expression

$.result[?(@.group[?(@=~/(administrators|jira-core-users)/ig)])]
CODE