Skip to main content
Skip table of contents

REGEX_IN_ARRAY

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:

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

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

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

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

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

Same but with an array of groups in you data source

CODE
{
  "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 )) })])]

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

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

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.