$re = '/^([AC-FHKNPRTV-Y]\d{2}|D6W)\s[0-9AC-FHKNPRTV-Y]{4}$/m';
$str = 'D6W 1234
A23 0984
D00 AV92
Y63 1FHK
A00 0000
D44 N4X4
A65 F4E2
D6W FNT4
T37 F8HK
D14 N2Fz
a65 f4e2
D6W FNTO';
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