Extracting an e-mail from a multine-line text field
I have a mulit-line text field in a helpdesk app that is filled via mail.
It usually always looks like this:
---
Ticket T-15027
Ersteller Firstname Lastname (firstname.lastname@company.de)
erstellt am 05.04.2022, 09:18
Kategorie fF Services
Status Zugewiesen
Priorität normal
Beschreibung
Mit besten Grüßen
Firstname Lastname
Company GmbH
Tel: 0712343253670984233
E-Mail: firstname.lastname@company.de <firstname.lastname@company.de>
company.de
Please consider the environment before printing this email!
--
I wanted to extract the first appearance of the e-mail that starts in brackets in a calculation field via this formula (i used "(mailto:" instead of "(" because it ist formatted in html/markdown)
var str = @Problem-/ Ticketbeschreibung;
var a = str.split("(mailto:").pop().split(")").shift();
var b = str.indexOf("(mailto:") > -1 && str.indexOf(")") > -1 ? "["+ a +"](mailto:" + a + ")" : ""b
In general this calculation works but it doesn't show the first e-mail but the last one. Why is that? And how can I make sure it gets the first one.
Please sign in to leave a comment.
Comments
0 comments