Trying to extract date from description via regex

Robert Wen_Cprime_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 27, 2023

I have a similar problem to this question: https://community.atlassian.com/t5/Jira-questions/Pulling-date-in-string-with-REGEX-from-Description-trying-to/qaq-p/2415519

My date field is in the middle of the Description.  It will be prepended with "Expected start date/effective date".  This is what it looks like:

Employee ID Number: N/A (Employee is a new-hire/rehire)

Expected start date/effective date: 2023-10-02

Is this a: N/A


This is my regular expression:

(?<=Expected start date\/effective date:\W*)(\d+[-]\d+[-]\d+)

here's where I want to put it:

 {{issue.description.match(“(?<=Expected start date\/effective date:\W*)(\d+[-]\d+[-]\d+)")}}

Putting it in an automation doesn't catch it.  Regex testers tell me the regular expression is good.  What am I missing? 

1 answer

0 votes
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.
September 27, 2023

Hi @Robert Wen_Cprime_ 

Please recall the match() function documentation about regular expressions says the "underlying implementation is based on Java's Pattern class", but it does not say what it actually does (and does not) support: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/#match--

My recommendations are:

  • First use a split() command prior to the match, either on newlines or on some pattern text near what you want.  That will reduce the scope the match needs to hit, and help you see when there are multiple matches (because it will return a list).
  • Use the simplest regular expression you can make that will do the job
  • When in doubt, build up the expression slowly, writing intermediate results to the audit log until it works as desired

Kind regards,
Bill

Suggest an answer

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

Atlassian Community Events