Regex pattern to extract date format ddMMMyyyy

Hi
I have this text “SAVE.INCOMING_418745_16MAR2021(1).ASCII.EPIN.TXT” i want a regex to extract 16MAR2021. Please how do I go about it again.
I wrote this (\d{2}\w{3}\d{4}) but i don’t think its efficient enough

Regards

Maybe this would do:

\d{1,2}\p{L}{3,4}\d{4}

Thank you . I am trying to achieve something that wouldn’t end up matching a string like “16COT2021” because COT is not a valid month

@MasterOfLogic

Check as below for your reference


Hope this may help you

Thanks

1 Like

What @Srini84 said but remove ^ and $ if you want to match text in the middle. Also you need the option IgnoreCase if the months are not always in upper case.

(([0-9])|([0-2][0-9])|([3][0-1]))(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)\d{4}

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.