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,556,658
Community Members
 
Community Events
184
Community Groups

Add string literals as a parameter to replaceAll

John Colosi
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!
Apr 07, 2023

I want to do this:

  • issue.description.replaceAll("||" + myParam + "|.*", "aReplacementString")

This would replace a certain table row in the description. The row that begins with myParam in the first cell. A table row looks like this:

  • ||Column1|Field A|FieldB|FieldC

 

But the problem is that you can't add strings together as a parameter (using the plus sign). You can append a string onto an existing value (using concat), but you can't prepend.

I considered using reverse/concat/reverse/concat, which looks ridiculous. Ultimately I did this:

  • issue.summary.left(0).concat("\|\|").concat(myParam).concat("\|.*")

This is probably equally ridiculous. I'm using the first 0 characters of the summary (a field I know exists) to create a temporary variable I can use to create my regex. I'm using the server version of Jira so I can't create a variable. I'm not sure what the right way to do this is. Any help appreciated.

1 answer

2 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.
Apr 07, 2023 • edited

Hi @John Colosi 

First, I want to note that is a clever work-around for no Create Variable action in the Server/Data Center version of automation rules.

Other approaches would be to store your search expression for the replaceAll() call in an entity property (or custom field), re-fetch, and then use that directly.  That would be slower but it might allow other regular expression content, possibly excluded by the smart value text function handling.

Kind regards,
Bill

Suggest an answer

Log in or Sign up to answer