Automation Regex - extract email address from Issue Description

Michael Jessopp June 3, 2021

I have an automation rule that creates a smart value variable "EmailReporter" using the following smart value 

{{issue.description.match((?<=User\: )(.*))}}

And the issue description contains the line

"User: first.last@domain.com"

I've used a regex validation tool (regex101.com) to validate the regex (?<=User\: )(.*) which locates the email address, but I can't this to work in the automation rule. I need the email address to be able to update the 'reporter' field.

Can anyone see what I'm doing wrong?

2 answers

1 accepted

1 vote
Answer accepted
Vikrant Yadav
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 4, 2021

Hi @Michael Jessopp  Try below regex code :- 

([a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+)

 

Thanks

Vikrant Yadav
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 4, 2021

{{issue.description.match("([a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+)")}}

Like Sateesh Dara likes this
gjuffer October 21, 2021

@Vikrant Yadav thanks for posting this.  I just tried it and it appears to return the email value twice.  Any thoughts on why that's happening?

Vikrant Yadav
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 21, 2021

Hi @gjuffer  Are you trying to insert email in ddscription field or in reporter ?

Above is for reporter field.

thanks

Like gjuffer likes this
gjuffer October 22, 2021

@Vikrant Yadav I've tried to insert as reporter and it kicked an error, so I tried to insert it as a comment and it returned "email@abc.com, email@abc.com".

When I enter the expression in a regex tester, it works fine.  I don't know much about regex (which is why I'm googling stuff) but it seems like maybe it has something to do with grouping?  Like maybe it's returning the original match and the group match?  Maybe I need to go back to school for a computer science degree.

Vikrant Yadav
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 22, 2021

Hi @gjuffer  Reporter of an issue you can only set, if user account is created in JIRA. If user is not created then JIRA can't set email address as reporter. Do reporter have jira account ?

Thanks

gjuffer October 22, 2021

@Vikrant Yadav we have another automation that creates a new account from an email, that part is not a problem.  The problem is getting only one email out of the description text, not the same email twice, separated by a comma.  It must be something about how regex and JavaScript are interacting within the automation.  I should probably just start a separate ticket.

Vikrant Yadav
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 25, 2021

Hi @gjuffer  it seems that Description field is having email address mutiple times.

Check following link to capture correct email address from description, hope it works for you :- 

https://community.atlassian.com/t5/Automation-questions/How-can-I-pull-the-email-address-from-the-Description-section-of/qaq-p/1521498

 

Thanks

V.Y

0 votes
Sergiy Dolnyy June 4, 2021

Positive look behind (?<=User\: ) might not be supported.

If you can use capturing groups, something similar to this might give you solution.

regexr.com/5ucd5

The mail address will be in group 2.

Suggest an answer

Log in or Sign up to answer