I want to match a date-format in PHP using a regular expression. To keep it simple, it can be extended later anyway, the regex should also match 2012-30-60 (which is not a valid date).
My expression is the following: "/\s*\d{4}-\d{2}-\d{2}\s*/i". Using preg_match works fine, but it also matches dates that have preceding and appending characters, like "Hello 2012-09-01 Goodbye."
How can I make the regex to match only when the expression matches the whole string?
^ means “begin of string/line”
$ means “end of string/line”