$re = '/^(?!cm1[12]$)(cm[1-5]|cm1[3-7]|cm99|ig[2-3]|ig[6-7]|me3|rm[1-9]|rm1[0-9]|rm20|ss0|ss1[1-7]|ss2|ss22|ss[4-9]|ss99)$/m';
$str = 'cm12
cm11
cm99
cm15
cm67
cm6
ss0
ss12
cm12
ss62
';
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