Regex date validation for yyyy-mm-dd
android, date, java, regex, validation
Solution
This will match `yyyy-mm-dd` and also `yyyy-m-d`:
^\d{4}\-(0?[1-9]|1[012])\-(0?[1-9]|[12][0-9]|3[01])$
If you're looking for an exact match for `yyyy-mm-dd` then try this
^\d{4}\-(0[1-9]|1[012])\-(0[1-9]|[12][0-9]|3[01])$
or use this one if you need to find a date inside a string like `The date is 2017-11-30`
\d{4}\-(0?[1-9]|1[012])\-(0?[1-9]|[12][0-9]|3[01])*
https://regex101.com/r/acvpss/1
Problem
what is the regex for the date format yyyy-mm-dd? I want to validate the email from edittext and check if it matches the regex.