I'm looking to write a RegEx to validate user inputted date formats like "DD/MM/YYYY" (NOT date validation)
I'm new to RegEx, but so far i have the following:
(D{2}|M{2}|Y{2,4})[-|/]?(D{2}|M{2})[-|/]?(D{2}|M{2}|Y{2,4})
This matches the following date formats:
- DD/MM/YYYY
- MM/DD/YYYY
- DD-MM-YYYY
- MM-DD-YYYY
- DDMMYYYY
- MMDDYYYY
- YYYYMMDD
- YYYYDDMM
- YYYY/MM/DD
- YYYY/DD/MM
- YYYY-MM-DD
- YYYY-DD-MM
- DD/MM/YY
- MM/DD/YY
- DD-MM-YY
- MM-DD-YY
- DDMMYY
- MMDDYY
- YYMMDD
- YYDDMM
- YY/MM/DD
- YY/DD/MM
- YY-MM-DD
- YY-DD-MM
But unfortunately, also matches the following:
- DDMMDD
- YYMMYYYY
- MMMMMM
Is there any way to only match the formats specified in the first list? The RegEx will be being used in VBA form validation.