Dear Community,
I try to use a complexe regex to parse an mail adress from a specific scheme of a ticket summary.
Which smart value is able to use the result of this regex as "send to" in the "send mail" component in an global automatition.
The expression was successfully tested in an regex tester.
(?<=Created.*?via.*?e-mail.*?received.*?from: .*? <)([-A-Za-z0-9!#$%&'*+=?^_`{|}~]+(?:\.[-A-Za-z0-9!#$%&'*+=?^_`{|}~]+)*@(?:[A-Za-z0-9](?:[-A-Za-z0-9]*[A-Za-z0-9])?\.)+[A-Za-z0-9](?:[-A-Za-z0-9]*[A-Za-z0-9])?)
Thanks in advance for your support.
Hi @Lucas Anschuetz -- Welcome to the Atlassian Community!
As the documentation states, with my emphasis, the "underlying implementation is based on Java's Pattern class and uses Matcher.find() to find matches." However, it does not state what is (and is not) supported by that implementation.
https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/#match--
My experience and several community posts indicate things which work in other tools / programming languages for different flavors of regular expressions do not work in automaton rules.
Something I note in your expression is it has multiple groups and automation rules appear to only support the first one, regardless if it is a capture or non-capture.
My recommendations:
When you are done, please post which expression actually worked for you to benefit the community. Thanks!
Kind regards,
Bill
Hi @[deleted],
Thanks for your fast reply.
My regex was in javascript flavor, so i created a new one matching to Java with only one group.
Several Java Regex testers I used where successfull.
The automatition runs without an error, but i get no result.
\[Created via e-mail received from: .+ <([^>]+)>\]
Do you maybe have another hint for me?
Thanks in advance
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Would you please post an image of your complete rule, an image of the action using that expression, and an image of the audit log details showing the rule execution?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for that information, Lucas. Please try to stick to one thread when posting. That will help others looking at this thread in the future know if there are multiple ways to solve the problem.
Back to your question...
I noted that you are searching the Summary field but the text you want to search is in the Description field. Which is correct?
I adjusted your expression to use a Description field, and added a split on newlines before the match and it worked for me:
{{issue.description.split("\n").match("\[Created via e-mail received from: .+ <([^>]+)>\]")}}
This version of match() does not handle the newlines, and so I often split on them to reduce the search complexity. When keeping the newlines is desired, I will replace them with a token first (e.g. MYNEWLINE), perform the match, and then swap them back.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry, I clicked the wrong button to answer.
My test was successful. I meant the issue description but used the wrong smart value.
Like you wrote, this smart value including the regex is correct:
{{issue.description.split("\n").match("\[Created via e-mail received from: .+ <([^>]+)>\]")}}
Thank you for your kind help and idea input!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is the rule overview:
If ticket is opened -> Then send mail to. Smart value in mail subject.
Used smart value: {{issue.summary.match("\[Created via e-mail received from: .+ <([^>]+)>\]")}}
I created an ticket with the part where the regex should match:
In the audit log, the run was successful.
But the mail I receive, the result is missing:
This is the result of my java regex test:
If I should provide further or more detailed information, just let me know.
Best regards
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.