I want to validate a string to see if it is a valid date in the format YYYY-MM-DD. I'm not very good with regex, but I've managed to get it to validate strings with four 0-9 characters in the beginning followed by the hyphen, followed by two 0-9 chars, another hyphen, and two more 0-9 chars in the end. How could I make this regex match dates with only 1-12 in the month and 1-31 in the day?
Here's what I have so far:
([0-9]{4})-([0-9]{2})-([0-9]{2})