Regular expression for date dd-MMM-yy

Hi, anyone have the regular expression for date dd-MMM-yy? E.g. 28-FEB-18, 06-APR-17 etc

Needs to be suitable for UiPath. Thanks

\d{2}-\w{3}-\d{2}

2 Likes

datetime.Now.ToString(“dd-MMM-yy”)

this case would return correct if someone were to type 95-ABC-03 so it isn’t so robust to detect correct dates

1 Like

Why any file has this format string 95-ABC-03, can you specify what the above string is representing

the underlying document may not contain a string like 95-ABC-03 but the workflow should be able to pick it out as an invalid date, and only capture the line if it is a valid date

why not use the above regex and pass it to this to check for validity

Yes what you told is correct but in real time scenarios you don’t have date alone

For ex

Invoice date: 14-mar-19

So you make Invoice date: as constant and take the value after that.

(?<=Invoice date: )\d{2}-\w{3}-\d{2}

^\d{2}-(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)-\d{4}$

In the case of 95-ABC-03 you could also use DateTime.Tryparse to check if the read out value is a correct datetime.