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

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,459,111
Community Members
 
Community Events
176
Community Groups

Regex is duplicating parts of a URL

Edited

Hey everyone, 

I'm trying to create an automation that when a link to an external Jira issue is added to the comments, it pastes the link into a custom External URL field. I'm new to regex so to test it I'm just having Jira bot return a comment with the URL.

When I add the URL into a comment as a hyperlink, Jira bot returns the URL back twice. However, If I paste a non-hyperlinked URL into the comments, it works correctly.

2021-07-29_13-41-09.png

I'm not exactly sure what I'm missing when I try to insert {{issue.comment.last.body.match("(https:\/\/jira.test.com\/browse\/ABC-\d+)")}} into the comment. 

2021-07-29_13-46-46.png

Any help is greatly appreciated. 

1 answer

1 accepted

0 votes
Answer accepted

Hi @Patrick Haley 

If you were to export that issue with the comment and look at the body, I expect you will see it includes something like this

[https://jira.test.com/browse/ABC-135|https://jira.test.com/browse/ABC-135|smart-link]

So the URL is in there twice and so needs to be parsed accordingly, such as using the Match to make it a list, and then returning only one entry.

Best regards,
Bill

How do you make a list from the match and then return just that value?

I can think of two ways to accomplish your goal:

  • no list: Modify the regex to account for that pipe symbol (so you only get one URL), and then strip off the extraneous characters with the replaceAll function
  • with list, and easier: Please note in your comment how Match added a comma between the values, so it should already be a list.  You can just grab one by adding .first after your Match call.

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events