Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

×
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

Issue Linking Using Regex in Jira Automation

Edited

Hello Jira Community,

I'm facing an issue with using regular expressions (regex) in Jira Automation to link one issue to another based on a custom field. I'm having trouble getting the regex to work correctly in Jira Automation, even though it functions as expected on online regex testers like regex101.com and freeformatter.com.

Here's an example of what I'm trying to achieve: I want to extract the last string after a slash (/) or an equal sign (=) from a URL (stored as text in a custom field). In other words, in the following inputs, the expected result of the regex should be "US-61" and "US-70," respectively:

I've been attempting to use the following regex pattern:

[^=\/]+(\/)?$

I've placed this regex within a smart value, so it looks like this:

{{fields.customfield_10184.match("[^=\/]+(\/)?$")}}

However, it doesn't return any results in Jira Automation.

When I tested with two different regex patterns (one to capture the last value after an equal sign and another to capture the last value after a slash), it worked as expected.

Please keep in mind that I tested all these regex patterns in online validators, and they worked as intended.

Can someone help me understand why this regex pattern isn't working in Jira Automation and suggest a solution?

Thank you for your assistance!

 

UPDATE: 

I tried to use the following regex:

  • ([A-Z]{2,}-\d+).*
  • [A-Z]{2,}-\d+.*

But it's not recognized as a smart value, unlike the previous one.

image.png

 

Here's the smart value:

{{fields.customfield_10184.match("([A-Z]{2,}-\d+).*")}}

1 answer

1 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.
Oct 19, 2023

Hi @Milena Prieto -- Welcome to the Atlassian Community!

First thing, context is important for solving problems with automation rules.  I recommend posting an image of your entire rule, images of any relevant actions / conditions / branches, and an image of the audit log details showing the rule execution.  Together those may help explain a symptom.

Next thing, what is the type of your field?  Is it text, single-select, multi-select, etc.?  The type of field can have an impact on the behavior of the match() function.

Next, what are the contents of your field, if it is text?  Specifically, does it have any newlines, bullets, etc.?  If so, that can impact the behavior of match.  The work-around for that is to add a split on newlines immediately prior to the match call, with split("\n")

Finally, and perhaps most importantly for your scenario: the match function documentation states that the regular expression parsing is based upon the Java Pattern class.  But it does not state what is / is not supported.  You may find several community posts where a regular expression worked elsewhere but not in an automation rule.  My recommendation is to use the simplest expression that could work, and test thoroughly.  And if that still does not work, revert to simple text functions and variables, as needed.

Kind regards,
Bill

Thank you for your help!
I followed your suggestion to try new regex, and this time, I tried one from Atlassian, which initially didn't work for my case. However, I made some adaptations and finally managed to make it work:

((?<!([A-Z]+)-?)[A-Z]+-\d+)

Grateful for the assistance!

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer