Forums

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

Parse comments using regex

Randy Simes April 20, 2022

When a defect is closed, I'm trying to parse all of the comments for specific values to build a report. The value I am looking for is like the following: ##.##.####. I've tried both the {{#issues.comments.match("([0-9][0-9]\\.[0-9][0-9]\\.[0-9][0-9][0-9][0-9])"}}... and issue.comment.match styles. Both execute successfully but return nothing on the match. This comment could be first, last, or somewhere in between but always has the same syntax.

1 answer

1 accepted

0 votes
Answer accepted
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.
April 20, 2022

Hi @Randy Simes -- Welcome to the Atlassian Community!

I note at least one missing parenthesis to close the match() function...and...

Without seeing the remainder of your rule, perhaps try using smart list filtering:

https://community.atlassian.com/t5/Automation-articles/Filtering-smart-value-lists/ba-p/1827588

Or, split the items into a list first and then try to match on the {{body}}

{{#issues.comments}}{{body.match("([0-9][0-9]\\.[0-9][0-9]\\.[0-9][0-9][0-9][0-9])")}}{{/}}

Kind regards,
Bill

Randy Simes April 21, 2022

Splitting the items into a list and matching on the body worked! Thank you.

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer