Does smart value support substringsBetween functions for automation

zhangqian04 June 24, 2020

hi,

ask for help:

I want a function to get the content of a string in the specified format, and return an array of strings, and take them out in turn.

 

eg. {{issue.XXX.substringsBetween("[","]").get(0)}}   or

{{issue.XXX.substringsBetween("[","]").[0])}} 

//this return String[] ,I want get  first、second...,but fail

best regards!

2 answers

1 accepted

1 vote
Answer accepted
Sam Harding
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 28, 2020

Hi,

This is possible to do, as the smart values supports regular expressions on its Strings. I believe the correct syntax for doing what you want is the following:

{{issue.XXX.match("(\[.*?\])").get(0)}}

The matching regex here will return a list of all strings which are between a [ and ]. The results will include the square brackets. If you would like to not include the square brackets in the results in the array, you can access the elements like so

{{issue.XXX.match("(\[.*?\])").get(0).substring(1,-1)}}

Hope you find this useful!

Thanks

zhangqian04 June 28, 2020

thanks very much ! 

This method is good !

Like Sam Harding likes this
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.
June 24, 2020

Hi @zhangqian04 

I had a similar issue accessing the results using the Split function for smart values... the documentation is not correct/complete.

When accessing a list, the correct syntax is {{somelist.first()}}   {{somelist.last()}}  or {{somelist.get(n)}} where the list is a zero-based array.

Here is what I found: https://community.atlassian.com/t5/Jira-Software-questions/JIRA-automation-and-a-working-example-of-the-Split-function-for/qaq-p/1395718

Try getting your substring, and then use Split() on it because substringBetween() returns a string, not an array.

Best regards,

Bill

zhangqian04 June 27, 2020

thanks firstly.

I want to use substringsBetween ,not substringBetween,  substringsBetween return  string array.

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer