If i am not mistaken, it should answer the question
// 2 capital letters, 2 numbers, is greater than 8 chars and ends with either the letters 'abc' or 'def'
$tst=explode(",","a1bAy7uBdef,a1uiBabc,AB45abc,ABC456def,AyuBhu56deg,hkjERabd,hkjER37Abc");
foreach ($tst as $v) {
echo "<br><b>$v</b>";
if (preg_match("`(?=(?:[^A-Z]*[A-Z]){2})(?=(?:\D*\d){2})(?=(?:.){5,}(abc|def)$)`",$v)) echo " ok !";
else echo " no pasaran !";
}