Rommel Rommel - 4 months ago 11
Python Question

Regex for this date format?

I searched and no one posted about this, Im kinda new with regex, but I want to learn more, so I need a regex search for this date format:

3-Jul-16 or 30-Jun-16
I want the regex to search any date format that can look like that.

Answer

Split the task into 3 parts. First, a number in the range of 1-31 (tutorial), then a list of possible values for the month, and then two numbers.

\b([1-9]|[12][0-9]|3[01])-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d{2})\b

Regex101 Demo