$re = '/^((0?\d)|([12]\d)|(3[01]))?\.?((0?\d)|(1[012]))?\.?((\d)|(\d\d)|(\d{3})|(19\d\d)|(20[0-3]\d))?$/m';
$str = '23.04.1988
5.9.11
12.12.20
02.02.02
02.02.0
02.02.
02.02
02
9
32.02.1999
12.13.2017
a2.03.2017
5.13.
12.12.1880
12.12.2100
';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
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