Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Regex to extract number from summary not working

Edited
Jason Barber
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
Oct 04, 2023

I am attempting to extract a 6 digit number from the summary when certain text are present, my rule is successful but the regex is not entering into the field. 

edit issue expression:

{{issue.summary.match(/\d{6}/gm)}}

String example:

COMPANY SO # 123456

I am expecting "123456" to populate my custom field however it remains empty. on regedex101 the statement works correctly. 

What am I missing?

2 answers

0 votes
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.
Oct 07, 2023

Hi @Jason Barber -- Welcome to the Atlassian Community!

Two things to consider when using the match() function in automation rules...

First, the documentation describes the "underlying implementation is based on Java's Pattern class and uses Matcher.find() to find matches".  However it does not indicate what actually is (or is not) supported for regular expressions.  I recommend using the simplest expression that can possibly work, and always test to confirm the results.  Especially for any edge-cases.

Next, the match() function for rules returns only one match, and appears to treat line breaks as points to stop searching.  (Please see my above paragraph...)

The work-around is to always split on newlines first before attempting matches.  This will potentially result in a list of responses, and so ensure you handle that.  For your expression, try adding .split("\n") before the match() call.

Kind regards,
Bill

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.
Nov 04, 2023

Hi @Jason Barber 

Just following up to check if this answered your question.  If so, please consider marking this one as "answered".  That will help others with a similar need find solutions faster.  If not, please let the community know what help you need with the rule changes.

Thanks!

0 votes
Kseniia Trushnikova
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Oct 05, 2023

Hi @Jason Barber,

Try this instead:

{{issue.summary.match("([0-9]{6})")}}

Will it work?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events