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!
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thanks firstly.
I want to use substringsBetween ,not substringBetween, substringsBetween return string array.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.