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 |
| A list of values that will be used to build the regular expression pattern. Can be used to retrieve context values from |
Context Filter Example:
For example, consider the following data source JSON:
{
"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:
$.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
$.result[?(@.group=~/(administrators|jira-core-users)/ig)]
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 ....
]
}
$.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
$.result[?(@.group[?(@=~/(administrators|jira-core-users)/ig)])]