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

JIRA Smart Values replaceAll question about regex

CS October 10, 2020

Hi there, I've been trying to get our email template (leveraging JIRA SD's new Project Automation features) to pick up images and (eventually) other unparsed content as well.

 

Here are some of the variations of the regex I have tried:

.replaceAll("!(.+?\.\w{3,4})\|width=(\d+),height=(\d+)!/gi", "<img src='$1' width='$2',height='$3'")

.replaceAll("/!(.+?\.\w{3,4})\|width=(\d+),height=(\d+)!/gi", "<img src='$1' width='$2',height='$3'")

.replaceAll("!(.+?\.\w{3,4})\|width=(\d+),height=(\d+)!/gi", "<img src='\1' width='\2',height='\3'")

and several other forms of it.

When I plug in the values on regex101.com, it finds the match no problem.

https://regex101.com/r/LNcuqg/1

_AcbHpawRi6hOrxiScUfuQ

 

 

Can anyone see what i'm doing wrong? I would love to be able to parse the images and translate them into html using regex so we can have inline images for our ticket reply emails! Happy to provide any additional info needed.

I feel like this would probably help others too. I can't find anything online that is JIRA Service Desk specific. (Yes, I've read the documentation)

https://support.atlassian.com/jira-software-cloud/docs/smart-values-text-fields/#Smartvalues-textfields-replaceAll(Stringregex,Stringreplacement)

https://docs.oracle.com/javase/7/docs/api/java/lang/String.html#replaceAll%28java.lang.String,%20java.lang.String%29

 

2 answers

0 votes
Richard Vencu October 16, 2020

I am also experimenting with this. I was not able to use $2 at all, only $1 appears to be working. Thus I struggled to obtain what I want inside $1, when not possible I continued the text processing with another replace() to remove leading and trailing characters

Also checking matches only does not help, you need to make sure $1 is what you want in your testing tool.

Finally, I got some results but then while $1 value looks OK in the testing tool in Jira automation I am always missing the last character for some reason... Still debugging

0 votes
wwalser
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 11, 2020

Please attach an image of your automation configuration. I'd like to take a look at that in order to replicate on my own system.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events