Sorry in advance if this is a repeat question. I didn’t see it listed elsewhere.
I’m trying to find a regex string that will recognize a date of birth in the format of mmddyy. As far as I know though, regex doesn’t know where individual number sets begin/end if they’re right next to one another.
Is there a simple way to get regex to find this (WITHOUT requiring delimiters/spacing)?
How about something like:
The first group would be two digits for the month, the next group would be two for the day, and the last group would be the year.
If you wanted to be smarter, you could make sure the first group starts with a 0 or a 1, and the day should start with a 0, 1, 2 or 3. Perhaps:
You also might not really need to use RegEx if you don’t want to. Most every single modern framework these days (Python, .NET, Java, whatever) has libraries and methods to parse dates in a specified format. That would have the added benefit of type checking and the ability to build a native Date object as well.
UPDATE:
You could use an OR to verify the day doesn’t go over 31: