$iterator = new RegexIterator(
new DirectoryIterator(
$dir2,
FilesystemIterator::KEY_AS_PATHNAME
| FilesystemIterator::CURRENT_AS_FILEINFO
| FilesystemIterator::SKIP_DOTS
),
'~[^a-d]~'
);
foreach ($iterator as $file_info) {
$filename = $file_info->getBasename();
};