A regular expression to match a valid day in a date string (from 1 to 31).
/(0[1-9]|[12]\d|3[01])/g
Matches:
- 01
- 31
- 29
Use this regex instead if you don’t want days with a preceding zero.
/([1-9]|[12]\d|3[01])/g
Matches:
- 1
- 31
- 29
See Also:
- Date (dd/mm/yyyy) Regular Expression
- 12-Hour Time (hh:mm:ss) Regular Expression
- 24-Hour Time (HH:mm:ss) Regular Expression
- Month Regular Expression
- Regular Expression To Match Names Of The Days Of The Week
- Regular Expression To Match Month Name
- Regular Expression For Year