Quote:
i need a regex expression which should be able to validate february in leap years i.e i should not be able to submit the page if the user gives 28-feb-2016 for a leap year.
In this case, you also need to check for months with 31 days and reject '31 Jun'. Last time I checked, '28 Feb' was correct every year, leap or not.
Even if possible, what you want to do with RegEx is kind of abuse.
I would use RegEx to check date format roughly '99 aaa 9999', and then a piece of JS code once I know the format is correct.
The problem with checking deep details with RegEx, is that the RegEx will degenerate as you introduce those details. The problem is that you can't include calculus in the RegEx, and thus you have to describe every possibility that don't fit in general case.
Once you know the input match the general format of a date, a little 'simple) piece of JS code can check if year is leap or not (year % 4 == 0)
Just a few interesting links to help building and debugging RegEx.
Here is a link to RegEx documentation:
perlre - perldoc.perl.org[
^]
Here is links to tools to help build RegEx and debug them:
.NET Regex Tester - Regex Storm[
^]
Expresso Regular Expression Tool[
^]
This one show you the RegEx as a nice graph which is really helpful to understand what is doing a RegEx:
Debuggex: Online visual regex tester. JavaScript, Python, and PCRE.[
^]