Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing the Collection / List of regex match results in Jira Automation

Jes Kampman July 16, 2024

I am trying to get multiple results from a regex match and make use of those multiple results.   So, let's say my input string is:    

[{type=Group, value=5bf99101-2825-4cd4-b14b-90e5f611045e, display=Group1, $ref=https://api.atlassian.com/scim/directory/493514aa-110a-47d3-8543-f2bb06c28954/Groups/5bf99101-2825-4cd4-b14b-90e5f611045e}, {type=Group2, value=4, display=GroupName2, $ref=https://api.atlassian.com/scim/directory/493514aa-/Groups/4]

I want to match on the value after "display=" and when I use a regex like :

{{GroupsString.match(".*?display=(.*?), .*?")}}

it seemingly correctly populates my variable "Matches", which prints out as :

 

Group1, GroupName2

However, my variable Matches does return any values for list expressions like, 'first', 'size', get(0) etc.

According to 

https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/  match()  it says " If multiple matches are found, they return as a collection that can be iterated."  but, as mentioned above, I cannot iterate this "collection" as a smart values list. 

Any ideas?

Thanks in Advance

1 answer

0 votes
Anthony Nguyen
Contributor
July 28, 2024

Same problem. I can see the collection by logging the smart value, but there seems to be no proper way to actually index into it. Some one suggested splitting the collection on commas, but that did not seem to help either.

Rodney Dsouza (Atlassian Certified Expert)
Contributor
August 12, 2024

I have had some luck saving the results of the match into a Object field by surrounding the results with double quotes i.e. using above example, make it "{{GroupsString.match(".*?display=(.*?), .*?")}}"

The Split function is not great but maybe this iteration helps your use-case

Suggest an answer

Log in or Sign up to answer