Text replacement with breaks
Asked by Ralf Fehling:

Hello everyone,

I use the mail handler from JETI to create issues based on HTML emails. This works as desired.

Because the body has a complex table structure, the result needs improvement. I would like to use Jira Automation for this. Simple text replacementsr \[*replace(String target, String replacement)*\] work well.

I want to remove the table in the header. As can be seen in the picture, the text to be target is spread over three lines.

![jira_automation.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/269392i27D5E3AE55A3EBB2/image-size/large?v=v2&px=999 "jira_automation.jpg")

I tried to identify the breaks with different variants - \\n, (\\n), \\r, (\\r), \\r\\n, (\\r)(\\n), \\\\. Unfortunately without the desired success.

What am I misunderstanding? Do you have a suggestion for me?

Thanks in advance!

Regards Ralf


Answers:
author: Tim Perrault
body: Hi [@Ralf Fehling](/t5/user/viewprofilepage/user-id/4255904)

So it looks like it is using [wiki notation](https://jira.atlassian.com/secure/WikiRendererHelpAction.jspa?section=tables). You could grab the the first 6 pipes and just replace it with nothing.

regex to grab the first 6 pipes: \[\|\]{6}

comments: author: Ralf Fehling
body: Hi [@Tim Perrault](/t5/user/viewprofilepage/user-id/165835)

The idea is not bad. I tried the replacement. But it doesn't work :(

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/270041iC434D43D5E6CA54F/image-size/large?v=v2&px=999 "image.png")

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/270042i707459F6367CAFF5/image-size/large?v=v2&px=999 "image.png")

Do you have an idea why it doesn't work?

Regards Ralf


author: Tim Perrault
body: [@Ralf Fehling](/t5/user/viewprofilepage/user-id/4255904)

Yea testing that out I can't get it to work. We could just eliminate everything up to a certain point though. Are all the notifications in the same format? If so, you could use the below regex to match everything up to the 9th pipe and replace that with nothing.

```
^([^|]*\|){9}
```

Before

![Screenshot 2023-07-20 141945.png](https://community.atlassian.com/t5/image/serverpage/image-id/270216iA2805CB4FB99EC1D/image-size/large?v=v2&px=999 "Screenshot 2023-07-20 141945.png")

After

![Screenshot 2023-07-20 142040.png](https://community.atlassian.com/t5/image/serverpage/image-id/270217i36BF7EFA7684AC53/image-size/large?v=v2&px=999 "Screenshot 2023-07-20 142040.png")


author: Arkadiusz Inglot
body: What if you use:

<br />

{{issue.description.substringAfterLast("\*(color:#BE")}}

or simillar approache?

comments: author: Ralf Fehling
body: Hi [@Arkadiusz Inglot](/t5/user/viewprofilepage/user-id/5254835)

Since I don't want to remove the entire header, this doesn't seem like a good solution for us.

Regards Ralf


author: Bill Sheboy
body: Hi [@Ralf Fehling](/t5/user/viewprofilepage/user-id/4255904)

I respectfully suggest it can be quite difficult to remove all the possible markup from the source \*and\* not lose any content within an automation for Jira rule. If you can find a way to send the source email as plain text, perhaps try that first.

Kind regards,  
Bill

comments: author: Ralf Fehling
body: Hi [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313)

we get the mail from an external agency. Unfortunately, it is not possible for us to select the output medium.

In order not to lose information, I want to define and replace the target as precisely as possible.

Attached is a sample and my current automation rules: [EML-File](https://www.dropbox.com/scl/fi/0yvkbfai2bcfsgra7xnm1/Vulnerability-Warning-DE-Badenia-UPDATE-Potential-HIGH-Vuln-18-07-2023-CVE-2023-1077-Linux-Kernel-Type-Confusion-Memory-Corruption-Vulnerability.eml?rlkey=3l60gynpsi4xt90qqduarmzp0&dl=0) / [Automation-rule](https://www.dropbox.com/scl/fi/lljzw9l2r5435xk55h606/automation-rule-22-202307180849.json?rlkey=lnqa9eb9k9ln5xzxq2zuotfzv&dl=0)

Regards  
Ralf


Tags: jira

jira-software