$re = '/^[A|C][1-9|A-HJ-PR-UW-Y][0-9][1-9|A-C][1-9|A-HJ-PR-UW-Y][0-9|A-HJ-PR-UW-Y]{3}[A-HJ-PR-UW-Y]{2}/m';
$str = 'A131K062CE04
A131K062CA04
A131K062CA
A131K062CE
A131K062CE
AZ31K062CE04
A136P099BH
A136Q09YBK
A136S02QCE
A136R09QAY
A136F04QBV
A136F08QAB
C136Q03UAU
A136D05BCG
A136B041AQ';
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