Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Automation Regex - extract email address from Issue Description

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

Hi @Michael Jessopp  Try below regex code :- 

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

 

Thanks

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

@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?

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

Above is for reporter field.

thanks

Like gjuffer likes this

@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.

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

@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.

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

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
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you