Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Using smart values within regular expression

Josiah Brown April 30, 2023

Problem:

  • I am trying to evaluate an automation rule which uses regular expression and was wondering if I can insert a smart value to be evaluated as part of the regex.
  • Trying to ensure the ticket's summary that is created matches the format needed including current date, trying to pull it from a smart value.

 

Steps taken to solve:

  • Basic testing by triggering the rule and seeing if it will be evaluated.
  • Checking documentation to see if what I'm trying to do is/isn't possible.

 

Regex string being evaluated:

\w{3}-\w{7,12}-(EKS|ECS|Lambda|Dynamodb|DynamoDB)-\w+-{{issue.created.format("mmddyyyy")}}-\d{1,2}

 

 

If anyone is able to find some documentation about this it'd be appreciated!

1 answer

1 accepted

1 vote
Answer accepted
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 30, 2023

Hi @Josiah Brown -- Welcome to the Atlassian Community!

Often the challenge is when there are nested quotation marks, as it seems you are trying: one set for the format() and another wrapping the regular expression.

I believe a work-around is to create the regular expression as a variable using Create Variable, and reference that as the expression.  For example: match(varMyCreatedVariableName)

And also...the regular expression parser is documented as based upon the Java one, and there are several posts showing it does not match.  When using a more complex expression, I recommend testing your expression by building it up in pieces, including a hard-coded date value, to confirm it works as you expect.

Kind regards,
Bill

Josiah Brown April 30, 2023

Good morning Bill,

 

Thank you for the welcome and your help!

 

I only have one set of quotations for my regex and that is for the format(). I'm not too familiar with your workaround but you think it'll allow my regex to contain the smart value I've provided? Very interesting.

I know the rest of my regex works and I've tested the portion with the date using some regex with just \d{6} so it's just the question as to if you can pair smart values inside of regex.

One workaround is to add a step to do simple matching and see if the summary contains {{issue.created.format("mmddyy")}}

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 30, 2023

I thought you were trying to use this regular expression in an automation rule, in which case the entire expression would be enclosed in quotation marks...unless it is already in a created variable.

If not in a rule, how are you using this regular expression?

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events