Hi,
I need to extract a date from a Description field. Below is a test sample ticket where the date is located in the line 'Please execute before'. Its in the dd-mm-yyyy format.
Currently, I'm using the smart value {{issue.description.match("Please execute before ([^\\n\\r:]*)")}} but that also catches the period at the end of the line. I've tried a lot of regex variations provided by AI (I'm not that great with regex myself, so it's just monkey see-monkey do). But all of them seem to be way to complex for Automation to handle. It either provides no feedback (empty Log action) or returns all kinds of errors about the smart value being incorrect.
Any tips on how to approach this? In the end, I want to fill the Due date of the ticket with the date in the Description minus 21 days. I know there is some 'minusDays(21)' option, but to get there, I first need to have an actual date without the dot, in the right formatting.
Any help would be greatly appreciated!
Hans
Hi @Hans Polder _Devoteam_
Thanks for the interesting question.
I tried the following, and it works.
Firstl,y it extracts the date, then it changes the format, making it YYYY-MM-DD, then adding .toDate() conversion, and lastly minus 21 days.
{{issue.description.match("Please execute before ([0-9]{2}-[0-9]{2}-[0-9]{4})").replaceAll("([0-9]{2})-([0-9]{2})-([0-9]{4})", "$3-$2-$1").toDate.minusDays(21)}}
I put the provided regex directly into the Due Date, and it was successfully set.
Hi Gor,
Wow, that's awesome! Thanks for your elaborate tests and reply. That worked perfectly. :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Hans Polder _Devoteam_
You are Welcome. Happy that it worked.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Hans Polder _Devoteam_
Have you considered and tried substringBetween()?
{{issue.description.substringBetween("Please execute before ",".")}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Trudy,
Thanks for that elegant solution. I will keep that in mind for future 'text mining'.
It exposed the date "29-09-2025" as expected without the dot.
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.