Match Date with Month spelled out

Published on Tue Mar 01 2022

Additional matching regexes for
Match Date with Month spelled out

Month Day, Year match

Match a date in the following Month Day, Year format: June 14, 2013

AutoDateRegex

Regex for date for example in saved reports (01m-1y) beginning of last month Format -> dmy

Date - Extract & Validate - Fully tested - Format YYYY-MM-DD (dynamic parts separator / can use a different separator)

A fully tested regex that extracts and validates date parts using named capturing groups. \ **Validations:** - Year must be preceded by nothing or a non-digit character - Year must have 4 digits - Month must be between 01 and 12 - Month must have 2 digits - Day must be between 01 and the maximum number of days for the month (e.g. february can't have more than 29 days) - Day must have 2 digits - Day must be followed by nothing or a non-digit character - Separator must be any single character that is not a space or an alphanumeric character - Separator must be the same between each date part \ **Capturing groups:** ```plain | # | Name | Description | |:-:|:-------:|-------------------------------------| | 1 | `year` | 4 digits of the year | | 2 | `sep` | Date parts separator | | 3 | `month` | 2 digits of the month | | 4 | `day` | 2 digits of the date (day of month) | ``` \ **Example usage:** ```js let match = regex.exec('2020-11-22') console.log('year: %s, month: %s, day: %s', match.groups.year, match.groups.month, match.groups.day) // year: 2020, month: 11, day: 22 ``` \ **Compatibility:** _(updated 2020-11-20)_ - Chrome >= 64 - Edge >= 79 - Firefox >= 78 - IE incompatible (lookbehind assertions & named capture groups not supported) - Opera >= 51 - Safari incompatible (lookbehind assertions not supported) - NodeJS >= 10.0.0 See [regex compatibility table](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Browser_compatibility). \ _**Note:** does not validate leap years (not really possible in regex)_

Regular Expression for Date

Regular expression for asp:RegularExpressionValidator with format MMddyy. i have resolved the issue for leap Year and month ending day as well.

yyyy/mm/dd

^(((\d{3}[1-9]|\d{2}[1-9]\d|\d[1-9]\d{2}|[1-9]\d{3})(\/)(((0[13578]|1[02])(\/)(0[1-9]|[12]\d|3[01]))|((0[469]|11)(\/)(0[1-9]|[12]\d|30))|(02(\/)(0[1-9]|[1]\d|2[0-8]))))|(((\d{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))(\/)02(\/)29))$ Match year/month/day, date format. E.g: 2021/08/25 [match] 2021/09/30 [match] 2018/02/28 [match] 2024/02/29 [match] 2023/02/29 [mismatch]

Regular Expression For Date

Regular expression for asp:RegularExpressionValidator with format MMddyy. i have Resolved leap year issue as well as month ending day issue with Regular expression

Timestamp

12.04.1975T03:02:00.88 With milliseconds and T seperator. Excludes most invalid dates, except 30/31ths of month, leap years/february heaving only 29/28.

Date regex

this regex check if the date is in the format d/m/Y H:i , it will not check the number of days in month

yyyy/mm/dd

^(((\d{3}[1-9]|\d{2}[1-9]\d|\d[1-9]\d{2}|[1-9]\d{3})(\/)(((0[13578]|1[02])(\/)(0[1-9]|[12]\d|3[01]))|((0[469]|11)(\/)(0[1-9]|[12]\d|30))|(02(\/)(0[1-9]|[1]\d|2[0-8]))))|(((\d{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))(\/)02(\/)29))$ Match year/month/day format. e.g: 2020/02/29 [match] 2021/02/29 [mismatch] 2021/08/25 [match]

php input:date yyyy-mm-dd

improved "Ahmed Z" regexp. PHP date format (and input[type=text] format date too): YYYY-MM-DD. Year between [1900-2099]. No leap year check. Month 02 is limited to 29 days.