Extract Content out of Description and Summary with Regex in Jira Cloud Automation
Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.
Summary
Learn how to create an Automation that extracts information from the description or summary and automatically dumps it into a specific field.
Solution
Before you begin
For this we will be assisted by REGEX.
REGEX is pattern based so you will need a couple of pre-requisites:
Example:
An email address is added to the text “Email: mail@testing.com“

In the above text, the likely outcome would be to extract the E-mail so it can be used to fill the Reporter field, create a new user account, or a multitude of options, which can be helpful to have.
In the above example “Email:“ would be my recognizable pattern and “email“ will be the text to extract.
As long as we have these elements the rest of the Description or Summary can be whatever, since we know what to look for.
The other two recommendations to follow are the following:
If used in SUMMARY the text to extract would need to be at the end of the field.
If used in DESCRIPTION, the text to extract needs to be in a separate line and always contain a line break.
The recommendation would be to use the Template as shown below:
Summary Example

Description Example

NOTE: These recommendations are made so that we introduce the least points of error into this process as possible.
Creating an Automation
Go to → Project Settings → Automation → Create Rule.
The structure will be the following:
Trigger: Issue Created is the most common trigger for this example; however, if you need to make edits because of any other trigger, you can do so as well.
Conditions: Can be any that you feel necessary.
Actions: These can be any that you feel necessary.
The only Action required will be the one on which we set the Extracted content.
Example
![Jira automation rule setup. When: Issue created. Then: Edit issue fields. The Reporter field is set with the smart value {{issue.description.match("\Email: (([S+]).)")}}.](https://images.ctfassets.net/zsv3d0ugroxu/Aao872u1Cid9IiQoaN2Q7/b7dd0c4f266e90d29cd658a588f90143/image2022-8-30_10-34-25.png)
The REGEX to use in this example is :
{{issue.description.match(".*Email: (\S+).*")}}
{{issue.summary.match(".*Email: (\S+).*")}}
Breaking this down:
The part ".*Email: (\S+).*
" will be our REGEX which translates to:
1
2
3
4
5
6
7
8
. matches any character (except for line terminators)
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
Email: matches the characters Email: literally (case sensitive)
1st Capturing Group (\S+)
\S matches any non-whitespace character (equivalent to [^\r\n\t\f\v ])
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
. matches any character (except for line terminators)
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
The rest of the line is the Smart Value that Allows us to use REGEX as part of our Automation.
For more information about Smart Values, you can review this document:
A couple of notes:
Be aware of spaces! if you introduce spaces into the REGEX and they are not present in the template this process can fail.
If you are modifying the REGEX, you can assist yourself with tools such as https://regex101.com/ so you can verify your changes against your text.
Was this helpful?