Skip to main content
Skip table of contents

REGEX_REPLACE

The REGEX_REPLACE function is used to match a regular expression pattern against a string content and replace all matches with a given string

Usable: Value Fields, Context Filter

Syntax: { REGEX_REPLACE((PARAM_1 PARAM_2 PARAM_3)) }

Parameter

Type

Example

Description

PARAM_1

JSONPath value

$.issue.fields.customfield_X
$.value

The JSONPath expression representing the value that should be matched against the regular expression pattern.

PARAM_2

String

'[^a-zA-Z0-1 ]'

The regular expression pattern to match against the value in PARAM_1

PARAM_3

String

'replace'

''

The replacing String of each match

Value Field Example

Extract all text up to the first whitespace:

CODE
{ REGEX_REPLACE(($.value '[^a-zA-Z0-1 ]' '')) }

If $.value contains '[remove] all // unwanted {}'&^!@^&($ characters' the result will be remove all unwanted characters.

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 in which the id equals the custom field value of the issue until the first whitespace:

CODE
$.result[?(@.id=={ REGEX_REPLACE(($.issue.fields.customfield_X '[^0-1 ]' '')) } )]

If the $.issue.fields.customfield__X field contains '1 (branch/name)' the resolved expression will be:

CODE
$.result[?(@.id==1)]

because only numbers are allowed and other characters are removed

JavaScript errors detected

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

If this problem persists, please contact our support.