- var_dump: documentation ( source)
- preg_match_all: documentation ( source)
<?php
$str = "PDOConnectionFactoryDB7";
$upper = '[A-Z]';
$lower = '[a-z]';
$numeric = '[0-9]';
$regex = "(^({$upper}{$lower}+" /* <-- Connection and Factory */
. "|{$upper}+(?!{$upper})" /* <-- PDO and DB */
. "|{$numeric}+" /* <-- 7 */
.")$)";
preg_match_all($regex, $str, $matches);
var_dump($matches);