“31/9/2010”, “31/09/2010” – September has 30 days only 10.
“31/6/2010”, “31/06/2010” -June has 30 days only 9.
You want to validate dates in the traditional formats mm/dd/yy, mm/dd/yyyy, dd/mm/yy, and dd/mm/yyyy.
“30/2/2008”, “31/02/2008” – leap year in February has 29 days only 5.Solutions 3 through 6 restrict the month to numbers between 1 and 12, and the day to numbers between 1 and 31.We use alternation (see Recipe 2.8) inside a group to match various pairs of digits to form a range of two-digit numbers.In this regex tutorial, we will learn to validate simple date formats e.g. Here, we want to use a regex that simply checks whether the input looks like a date, without trying to eliminate things such as February 31st.You might think that something as conceptually trivial as a date should be an easy job for a regular expression. The main issue is that regular expressions don’t deal directly with numbers.