Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Automation - using create variable to extract text

Priscille Lesne May 1, 2025

Hi, 

I want to extract a serial number that is in a middle of some text in my issue.summary. 
The format of my serial number is: "E-" followed by 7 numbers (i.e: E-1234567). 

I have created a variable: {{issue.summary.match("E-\\d{7}")}} but it returns nothing. 
I also tried:  {{issue.summary.find("E-\\d{7}")}} but it returns nothing. 

Any idea? 

Thank you! 

3 answers

3 accepted

2 votes
Answer accepted
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 1, 2025

Hi @Priscille Lesne 

The solution you found will match to any characters, and not just digits.  For example, E-abcdefg.

Please try this one to match only to the seven digits in the expression:

{{issue.summary.match("(E\-\d{7})")}}

 

Kind regards,
Bill

Priscille Lesne May 1, 2025

I've used Himanshi's solution {{issue.summary.match(".*(E-\\d{7}).*")}} and it matches only to the seven digits. 

 

What do the \ mean?

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 1, 2025

That depends upon what follows the forward slash character...

According to the Atlassian documentation, the "underlying implementation is based on Java's Pattern class and uses Matcher.find() to find matches", with emphasis added by me.

Thus \d is a digit, 0-9, and the forward slash may indicate other expressions or escape the character that follows.  For example, \- escapes the dash for use in the expression.

 

In my experience with Jira automation rules, one must experiment and fully test to know what does and does not work with their implementation of regular expressions.  This will prevent surprises, such as the known racetrack error problems when using regular expressions with different rule features.

Like Priscille Lesne likes this
2 votes
Answer accepted
Priscille Lesne May 1, 2025

I've solved my problem. I should have written: 

{{issue.summary.match("(E\-.{7})")}}

0 votes
Answer accepted
Himanshi
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 1, 2025

Hello Priscille, 

Welcome to the community! Thank you for sharing the use case with an example and attempted smart values. It was helpful for me to understand what di'nt work for you. 

You can try {{issue.summary.match(".*(E-\\d{7}).*")}} to fetch the Serial number. 

I added ".*" before and after the regex to indicate that the summary could start and end with any character. 

Please try this smart value and consider to mark this answer if it works for you.

Have a lovely day ahead!

 

Priscille Lesne May 1, 2025

That's great, it works! Thanks for the explanation! 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events