I divided a similar use case into three expressions as this was hard to put together in one expression.
- Search for the place where “country” is within the description: E1, e.g. returning 10
indexOf('{{ticket.description | sanitize_html | strip_html | escape }}','Country:', 0)
- Search for the place where “https” is (E2), e.g. returning 25
indexOf('{{ticket.description | sanitize_html | strip_html | escape }}','https:', 0)
- Add or substract a few numbers to exactly get the start or end of this string. e.g. “Switzerland” is between position 10 and 25 ± a small amount.
trim(substring('{{ticket.description | sanitize_html | strip_html | escape }}', {{E1.result}}+8, {{E2.result}}))
Not sure about the exact numbers you have to add or substract as we had this with another use case/strings.
Looks like a alarm, do you have pro or higher ?
You could use the alert module and e-mail into that.
Hello! Good day. Thanks for reaching out to us on the community.
Regarding your query, you can use the following expression:
{{ticket.description.substring(ticket.description.indexOf("Country: ") + 9, ticket.description.indexOf(" https://"))}}
Explanation:
-
ticket.description.indexOf("Country: ") + 9
: Finds where the country value starts, right after "Country: "
.
-
ticket.description.indexOf(" https://")
: Finds where the country value ends, assuming there's a space before the URL.
-
substring(start, end)
: Extracts the country name between these two indexes.