Pulling Data from Summary and Adding that to comments
Asked by Jay:

I am attempting to make tickets easier for my team to read. I previously posted about making custom variables and I'm not sure thats the path to go.   

The current goal is to take RegEx (which is verified) and use that to pull the required data from incoming tickets. Then taking that data that I need to pull, I want to create a comment with that data.  

I've attempted it and when I add the comment its always blank, I have made sure adding comments is working by adding plain text and that shows up.   

When attempt to use either regex or even save the regex as a variable, I get an error\>  

Action details: {#toc-hId--405925623}
-------------------------------------

##### [Manual trigger](https://payscale.atlassian.net/jira/servicedesk/projects/ISR/settings/automate#/rule/17547489/393797622) {#toc-hId-985700429}

User triggered the rule  

##### [Issue condition](https://payscale.atlassian.net/jira/servicedesk/projects/ISR/settings/automate#/rule/17547489/393797623) {#toc-hId--821754034}

The following issues passed:  
ISR-93  

##### [Comment on issue](https://payscale.atlassian.net/jira/servicedesk/projects/ISR/settings/automate#/rule/17547489/393797624) {#toc-hId-1665758799}

Error adding comment to issue  
Comment body can not be empty! (comment)  

If anyone can assist I would be grateful, if more information is needed I can provide some scrubbed email content that we are attempting to use.  
EDIT:  
Adding the smartvalues I'm attempting to use:  
{{issue.description.match(\[\\s\\S\]\*?(?=Recommendation))}}  
{{issue.description.match(\^Log\\sSource\[\\s\\S\]\*?(?=\\sCount))}}  
{{issue.description.match(\^Portal.+)}}  

<br />

EDIT:  

It did work for the first one, but the last 2 even like that are pulling empty. I tested the regex again and its capturing in regex testing, but still showing empty. If you could help 1 more time I'd really appreciate it.  

for first one:

Log Source Device Name : O365

Source IP : xxx.xxx.xxx.xxx

Source User : someone\[.\]random@regex\[.\]com

Alert ID : INSIGHT-81

Alert Date : 2024-01-19 12:39:28

Action : File Downloads

Count : 697

<br />

For the second one this is what it is looking for.

Portal - Ticket: 0002334


Answers:
author: Mark Segall
body: Hi [@Jay](/t5/user/viewprofilepage/user-id/5338484) - I haven't tested, but I believe you need quotes around your regex:

```
{{issue.description.match("[\s\S]*?(?=Recommendation)")}}
```

```
{{issue.description.match("^Log\sSource[\s\S]*?(?=\sCount)")}}
```

```
{{issue.description.match("^Portal.+")}}
```

comments: author: Jay
body: Thank you for your response. Unfortunately it is still showing as "empty" in the automation.


author: Mark Segall
body: Ok - I just played with the first one and it looks like you also need to encapsulate the regex in parantheses:

```
{{issue.description.match("([\s\S]*?(?=Recommendation))")}}
```


author: Jay
body: [@Mark Segall](/t5/user/viewprofilepage/user-id/4666637)   

It wouldn't let me reply, I have edited and added my reply to the bottom of the orriginal post, if you have a moment,


author: Mark Segall
body: These are working for me in my testing:

```
{{issue.description.match("(^Log\sSource[\s\S]*?(?=\sCount))")}}
```

```
{{issue.description.match("(^Portal.+)")}}
```


author: Joseph Chung Yin
body: [@Mark Segall](/t5/user/viewprofilepage/user-id/4666637) -

Nice finding... Thanks

Best, Joseph


author: Jay
body: Interesting...still comes back as "empty" on mine...I guess I'll keep poking it because clearly it is an issue on my side if its working for you. Thank you!


author: Mark Segall
body: Note for each of those last two, the regex requires the respective "Log Source" and "Portal" to be on the first line. I'm not sure if that's your intent. If it is, it worked for me in my testing and I literally copy/pasted the smart values from my environment after confirmed test.


author: Jay
body: Oh I wonder if thats the issue...in Regex101 it can grab it from anywhere in the big email, it sounds like that isn't working in Jira. Not sure if thats a Jira issue or Regex ;/


author: Mark Segall
body: I played around with it a little further and was able to make those last two work like this:

```
{{issue.description.match("((?i)Log\sSource[\s\S]*?(?=\sCount))")}}
```

```
{{issue.description.match("((?i)Portal.+)")}}
```

You may want to put it through more rigorous testing, but my tests returned desired results.


author: Jay
body: I'll put some testing in on this today and likely accept as answered. Thank you much, you are a super star!


author: Jay
body: [@Mark Segall](/t5/user/viewprofilepage/user-id/4666637) it works perfectly, you are my hero!


Tags: automation

cloud

jira-service-management

jira-service-management-cloud

regex