Regular Expressions 101

Community Patterns

date pattern


Regular Expression

(?=\b(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec|\d{4}|\d{1,2}))\w*[\t\ \\\/\.\,\;\:\-\+\_]+(\d{1,2}|jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\w*[\t\ \\\/\.\,\;\:\-\+\_]+(\d{4}|\d{1,2})\w*\b


This regex can read dates YYYY/MM/DD, dd/mm/yy, Month dd YYYY, YYYY Month dd where Month is the literal description of the month (jan, feb, mar, ..., dec). Use the ignore case flag. It has three capture groups. The regex doesn't handle the sequence logic, that has to be managed later on the captured groups.

Possible mishap occurs when presented with a sequence with two consecutive moths: Month - Month YYYY Although this may be interpreted as an interval between two months. The logic is left for later.

Submitted by anonymous - 8 years ago