I am attempting to extract a 6 digit number from the summary when certain text are present, my rule is successful but the regex is not entering into the field.
edit issue expression:
{{issue.summary.match(/\d{6}/gm)}}
String example:
COMPANY SO # 123456
I am expecting "123456" to populate my custom field however it remains empty. on regedex101 the statement works correctly.
What am I missing?
Hi @Jason Barber -- Welcome to the Atlassian Community!
Two things to consider when using the match() function in automation rules...
First, the documentation describes the "underlying implementation is based on Java's Pattern class and uses Matcher.find() to find matches". However it does not indicate what actually is (or is not) supported for regular expressions. I recommend using the simplest expression that can possibly work, and always test to confirm the results. Especially for any edge-cases.
Next, the match() function for rules returns only one match, and appears to treat line breaks as points to stop searching. (Please see my above paragraph...)
The work-around is to always split on newlines first before attempting matches. This will potentially result in a list of responses, and so ensure you handle that. For your expression, try adding .split("\n") before the match() call.
Kind regards,
Bill
Just following up to check if this answered your question. If so, please consider marking this one as "answered". That will help others with a similar need find solutions faster. If not, please let the community know what help you need with the rule changes.
Thanks!
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.