Last active
November 14, 2024 08:49
-
-
Save m-coding/c96d99558a47d30aef4992c6dd60437a to your computer and use it in GitHub Desktop.
javascript regex to match date pattern YYYY-MM-DD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// allows YYYY/M/D and periods instead of slashes | |
// http://stackoverflow.com/questions/24989065/trying-to-validate-yyyy-mm-dd | |
/^\d{4}[\/.]\d{1,2}[\/.]\d{1,2}$/ | |
// YYYY-MM-DD and YYYY-M-D | |
// http://stackoverflow.com/questions/6177975/how-to-validate-date-with-format-mm-dd-yyyy-in-javascript | |
/^\d{4}\-\d{1,2}\-\d{1,2}$/ | |
// YYYY-MM-DD | |
// https://gist.github.com/arth2o/8471150 | |
/(\d{4})-(\d{2})-(\d{2})/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
for what were used escape characters
\-
?!it can be changed to: