I have a date entry control on a UI. It auto-completes the date as numbers are typed.
Currently using:
\d{1,2}(\.|\/|-)\d{1,2}
Test on http://regexpal.com/ to see it working.
Basically 1 or 2 digits, followed by one of ./-, and 1 or 2 digits. e.g. 01/9, 1/2, 1/1, will match
What I’m looking to do (and can’t!):
If the second set of digits (the Month part) is 0 or 1, need another digit
If the second set of digits is 2-9, match
That’s it basically, thanks
Brian
Number ranges are a bit annoying in regex, and should maybe be done in a separate step, when the format is validated. But here is the regex:
That should match all the requirements (including the ones from the comments). Possible months: