$re = '/#проверка корректности даты в формате ГГГГ-ММ-ДД без проверки YYYY-02-29 в високосных годах (нужно доделать)
(?=^
(?:19|20)\d\d #1900...2099
-
(?: (?:0[1-9]|1[012]) #01...12
-
(?:0?[1-9]|[12]\d) #01...29
| (?:0[13-9]|1[012]) #monthForDay30
-
30
| (?:0[13578]|1[02]) #monthForDay31
-
31
)
$)
^(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})$/xms';
$str = '2018-01-00
2018-01-32
2018-00-01
2018-13-01
2018-01-01
2018-01-29
2018-01-30
2018-01-31
2018-02-29
2018-02-30
2018-02-31
2018-03-29
2018-03-30
2018-03-31
2018-04-29
2018-04-30
2018-04-31
2018-05-29
2018-05-30
2018-05-31
2018-06-29
2018-06-30
2018-06-31
2018-07-29
2018-07-30
2018-07-31
2018-08-29
2018-08-30
2018-08-31
2018-09-29
2018-09-30
2018-09-31
2018-10-29
2018-10-30
2018-10-31
2018-11-29
2018-11-30
2018-11-31
2018-12-29
2018-12-30
2018-12-31';
$subst = "${year}-${month}-${day}";
$result = preg_replace($re, $subst, $str);
echo "The result of the substitution is ".$result;
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php