# Using split regexp

**Use Case**

Customers frequently face the issue of having unnecessary or irrelevant content being added as a comment from a reply email to a particular issue.

An email often gets added as a comment to the issue including long threads of previous messages (e.g.: a reply email and the original event notification email to which the reply was sent).

Email This Issue supports the use of regular expressions as a way of separating the latest message from previous ones, and adding only relevant content from a reply email as a comment to the issue.

**How to solve this problem**

In this section we will show two different approaches to remove old content from reply emails, each with their own advantages and disadvantages.

**Reactive approach**

This is the classical split regex approach, which attempts to split the email body based on how various email clients format reply emails. The problem with this approach is that mail clients format reply emails differently which makes splitting difficult and prone to errors. Here are two examples of the two most widely used email clients (Gmail and MS Outlook). The red frames mark the expressions people usually try to match when wanting to use regular expressions.

**Gmail example:**

<figure><img src="https://880912854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mf8H-oTE_fhOrUtfYrN-2724419853%2Fuploads%2FTwKH7seLHCAF4En1ybaT%2Fimage.png?alt=media&#x26;token=f486b81b-1e7f-4bda-bc8d-84f8c753d4a5" alt=""><figcaption></figcaption></figure>

**MS Outlook email example:**

<figure><img src="https://880912854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mf8H-oTE_fhOrUtfYrN-2724419853%2Fuploads%2F9zHVemxZk6YK3EAZpQ8o%2Fimage.png?alt=media&#x26;token=1ae6e346-02a6-44bb-b1e6-444599fbe241" alt=""><figcaption></figcaption></figure>

**Note:** In the above MS Outlook example the reply is sent to an email that is marked by From: Sent: To: and Subject: text.

We recommend that for multi-language purposes you try using the following regular expression in order to escape the bold formatting as well: \s\*\\\*From:|\_\_\_.|On .wrote:|----Orig.|On .(JIRA).

<mark style="background-color:orange;">**Note: On cloud instances, split regex uses perl syntax, therefore it must be entered between forward slashes.**</mark>

<figure><img src="https://880912854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mf8H-oTE_fhOrUtfYrN-2724419853%2Fuploads%2F5OgDbtHGApLfE8vEmlq6%2Fimage.png?alt=media&#x26;token=16b561a6-5db3-4fdc-8100-d675c635783a" alt=""><figcaption></figcaption></figure>

**Note:** With this approach you don't have to modify templates, but it has many disadvantages. As it requires complex regular expressions, making it easy to mess up. It is unreliable, as the expressions depend on the mail clients, and there's a high probability of information loss.

**Proactive approach**

This approach attempts to split the email body at a well defined, previously known, unique marker.

Why we recommend using a **proactive approach** with Email This Issue:

* It is easy to use as it requires creating only one regex pattern.
* It does not depend on mail clients.
* Information loss is less probable.
* Visible markers improve customer usability.

The **proactive approach** has two small drawbacks:

* It requires the use of custom templates in which the markers can be placed.
* Due to the need of custom templates, you must implement issue notifications in Jira using Email This Issue (in case of non-service desk projects).

**Note:** We highly recommend using a proactive approach with Email This Issue.

**Step by step guide**

Using the following visible content marker will have only the latest email content above the delimiter be added as a comment.

1\. Simply add a delimiter to the top of the body in your email templates such as adding: --Please reply above this line--

<figure><img src="https://880912854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mf8H-oTE_fhOrUtfYrN-2724419853%2Fuploads%2F69DlzFf4Ka0Q0YmVFfSq%2Fimage.png?alt=media&#x26;token=aba01bad-0a4a-4f12-8dc4-66919c1ceb5f" alt=""><figcaption></figcaption></figure>

2\. Add a regular expression that matches the delimiter and don’t forget to insert it between forward slashes „/”

<figure><img src="https://880912854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mf8H-oTE_fhOrUtfYrN-2724419853%2Fuploads%2FQhnLihxI5uPTWfmAiwZY%2Fimage.png?alt=media&#x26;token=6dacfb3b-c140-4dcf-b03d-7f5c01d94a0f" alt=""><figcaption></figcaption></figure>

Result: If the above settings are carried out, then the following results are to be expected. The original email is cut using a visible content marker:

<figure><img src="https://880912854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mf8H-oTE_fhOrUtfYrN-2724419853%2Fuploads%2F5bGRllMyZUMZAuhcWFoe%2Fimage.png?alt=media&#x26;token=c4a38b17-bbd2-47e0-b19b-beead34051f8" alt=""><figcaption></figcaption></figure>

&#x20;Comment added to the issue, email cut above the visible content marker:

<figure><img src="https://880912854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mf8H-oTE_fhOrUtfYrN-2724419853%2Fuploads%2FMao17pS7w5epzyDEBchs%2Fimage.png?alt=media&#x26;token=0c9769f1-facf-4ffe-b651-fe7184aba5b5" alt=""><figcaption></figcaption></figure>

&#x20;

&#x20;

| HTML format | Wiki format |
| ----------- | ----------- |
| `<hr />`    | `----`      |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.meta-inf.hu/email-this-issue/adding-editing-a-mail-handler/email-this-issue-for-jira-cloud-mail-handler-actions/using-split-regexp.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
