Do not do this with Regex. Dates are formatted differently in different countries. Use the DateTime.TryParse procedure instead:
DateTime parsedDate;
if ( DateTime.TryParse( dateString, out parsedDate) && parsedDate.Day <= 28 )
{
}
Regex is almost a golden hammer of input validation, but in this case it is the wrong choice.
source
share