I've created an automation rule that scans the description of an incoming issue for an email address via a regex match, then adds a comment with that email address. The automation is set up like this:
The code looks like this:
{{issue.description.match("([a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+)")}}
This automation successfully finds the email address and adds it to the comment, but it repeats the email twice with a comma separation, such as:
example@address.com, example@address.com
It seems like the match function is returning an array. How do I return only a singular email address?
Hi @gjuffer
I hypothesize that is from how the email is put as markup in the description. So if it is returning a list, you could get just one value by adding .first or .last to the end of that expression.
Kind regards,
Bill
@Bill Sheboy thanks for the quick answer - I followed the link but am unsure if I'm using the correct syntax. I tried the following code and it did not work:
{{issue.description.match.first("([a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+)")}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please move the first to the end; this makes it apply to the returned list from the match():
{{issue.description.match("([a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+)").first}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Awesome; I am glad to learn that helped you.
__Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Well, I found a pretty useful video on Youtube from Ravi Sagar:
https://www.youtube.com/watch?v=jP90ckC29Kk
He suggested that you need to add .* before and after your regex. This worked for me, but I can't say that I understand why. The code that ended up working is as follows:
{{issue.description.match("(.*[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+.*)")}}
Fascinating. Looks like I need to learn more.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.