Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Page properties
hiddentrue
StatusTech review
Status
colourYellow
titleReady for review
StatuscolourRedtitlestaff pickStyle guide

Status
colourYellow
titleReady for review

Status
titletodo
Status
colourYellow
titleReady for review
Status
colourGreen
titledone
Status
colourRed
titleflagged

Page properties
hiddentrue
Short description

Returns all substrings matching a given regular expression.

Output Statussubtletruetitletext list UI Text Box
sizemedium
typeinfo

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

Code Block
languagebash
titleSyntax
linenumberstrue
findPattern(text, regex) #Output: Text list
UI Expand
titleExamples
true

Assuming %{issue.lastComment} returns, e.g.

Hi [~demo] and [~user~Alina Grant|~accountid:5c90f542efd65d2d3d465d7c]!

this example returns the following text list:

["demo", "user"]

5c90f542efd65d2d3d465d7c

Parser expressionDescription


Code Block
languagebash
linenumberstrue
%{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"]


Code Block
languagebash
linenumberstrue
%{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"]

Extract all email addresses from a text field

Code Block
languagebash
linenumberstrue
%{findPattern(%{issue.somefield},"([amailto:)([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 (added as hyperlinks), 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"]


Processing an Elements Connect (formerly nFeed)* custom field 

Code Block
languagebash
linenumberstrue
%{findPattern(%{issue.somefieldlastComment},"(?<=:\[(\"|\",\"\~accountid:).*?(?=\"])")}

* Applicable for Elements Connect version 6 and above.

Assuming %{issue.somefield} is an Elements Connect (formerly nFeed
)
custom field containing the keys of the selected options, e.g.{ "keys":[ "KEY-1", "KEY-2", "KEY-3" ]
}

this example returns the following text list:

["KEY-1", "KEY-2", "KEY-3"]


Extract all user mentions from the last comment

Code Block
languagebash
linenumbers
%{findPattern(%{issue.lastComment},"(?<=\[~).*?(?=\])")}

 Extract all issue keys from the last comment

Code Block
languagebash
linenumberstrue
%{findPattern(%{issue.lastComment},"([A-Z][A-Z0-9]+)-\d+")}


Extract all issue keys from the last comment

Assuming %{issue.lastComment} returns, e.g.

Hi [~admin],

this issues seems to be related to DEMO-1 and DEMO-2! 

this example returns the following text list:

["DEMO-1", "DEMO-2"]

Extract all URLs from a text field


Code Block
languagebash
linenumberstrue
%{findPattern(%{issue.somefield},"(?<=\|http:\/\/|\|https:\/\/).*?(?=\])")}


Extract all URLs from a text field

Assuming %{issue.somefield} returns, e.g.

The best documentation can be found at [apps.decadis.net|https://apps.decadis.net]. Make sure to check the space for [Jira Workflow Toolbox|https://apps.decadis.net/display/JWT]! If you can't find what you're looking for there, all you have left is [Google|https://www.google.com].

this example returns the following text list:

["apps.decadis.net", "apps.decadis.net/display/JWT", "www.google.com"]

UI Expand
titleAdditional information

Parameters used in this function

ParameterInput (data type)Description
text

Status
subtletrue
titletext

Any given text.
regex

Status
subtletrue
titletext

A valid regular expression that grabs all substrings to be returned.

UI Expand
titleOutput

This function returns a

Status
subtletrue
titletext list

UI Text Box
typetip

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

Parser expressionOutput


Code Block
languagebash
linenumberstrue
findPatternIgnoreCase("Grass is Green and Sky is Blue.", "red|green|blue")


["Green", "Blue"]


Code Block
languagebash
linenumberstrue
findPattern("Grass is Green and Sky is Blue.", "red|green|blue")
[ "Green", "Blue"][ ]]


Image AddedUse cases and examples

Page properties report
firstcolumnUse case
headingsJWT feature, Workflow function, Field type, Automated action, Parser functions
cqllabel = "parser_func_findpattern" and space = currentSpace()


Excerpt Include
DECADIS:Contact support
DECADIS:Contact support
nopaneltrue


Page properties
hiddentrue


Short description

Returns all substrings matching a given regular expression.

Output

Status
subtletrue
titletext list