You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 17 Next »

This function returns a text list with all substrings matching a given regular expression.

Syntax
findPattern(text, regex) #Output: Text list
Examples
Parser expressionDescription
findPattern("Between 1900 and 2000 world population increase from 1.5 to 6.1 billions.", "\\d+(\\.\\d+)?")

This example returns the following text list

["1900", "2000", "1.5", "6.1"]

findPattern(%{issue.someField}, "(?<=CN=).*?(?=,OU=Users)")

Assuming %{issue.somefield} is a multi-line text field containing a list of Active Directory user entries, e.g.

CN=User1,OU=Users,DC=example,DC=com
CN=User2,OU=Users,DC=example,DC=com
CN=User3,OU=Users,DC=example,DC=com
CN=User4,OU=Users,DC=example,DC=com

this example returns the following text list:

["User1", "User2", "User3", "User4"]

findPattern(%{issue.someField},"([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\\.[a-zA-Z0-9_-]+)")

- Extract all email addresses from a text field.

Assuming %{issue.somefield} is a multi-line text fiel containing email addresses, e.g.

Hello,

please use admin@example.com instead of administrator@example.com for future reference.

Kind regards,
jwt@example.com

this example returns the following text list:

["admin@example.com", "administrator@example.com", "jwt@example.com"]

Additional information

Parameters used in this function

ParameterInput (data type)Description
text

TEXT

Any given text.
regex

TEXT

A valid regular expression that grabs all substrings to be replaced.
Output

This function returns a TEXT LIST

If you want to ignore the case, have a look at the findPatternIgnoreCase() function.

findPatternIgnoreCase("Grass is Green and Sky is Blue.", "red|green|blue")findPattern("Grass is Green and Sky is Blue.", "red|green|blue")
["Green", "Blue"][ ]