protected function dirRegexIteration($dir, $regex)
    {
        $dir   = (string) $dir;
        $regex = (string) $regex;

        $dir_iterator      = new \RecursiveDirectoryIterator($dir, \FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::CURRENT_AS_SELF | \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::UNIX_PATHS);
        $iterator_iterator = new \RecursiveIteratorIterator($dir_iterator, \RecursiveIteratorIterator::CHILD_FIRST);
        $regex_iterator    = new \RegexIterator($iterator_iterator, $regex, \RegexIterator::MATCH, \RegexIterator::USE_KEY);

        return $regex_iterator;
    }
protected function dirRegexIteration($dir, $regex)
    {
        $dir   = (string) $dir;
        $regex = (string) $regex;

        $dir_iterator      = new \RecursiveDirectoryIterator($dir, \FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::CURRENT_AS_SELF | \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::UNIX_PATHS);
        $iterator_iterator = new \RecursiveIteratorIterator($dir_iterator, \RecursiveIteratorIterator::CHILD_FIRST);
        $regex_iterator    = new \RegexIterator($iterator_iterator, $regex, \RegexIterator::MATCH, \RegexIterator::USE_KEY);

        return $regex_iterator;
    }
protected function dirRegexIteration ( $ dir , $ regex ) { $ dir = ( string ) $ dir ; $ regex = ( string ) $ regex ; $ dir_iterator = new \ RecursiveDirectoryIterator ( $ dir , \ FilesystemIterator :: KEY_AS_PATHNAME | \ FilesystemIterator :: CURRENT_AS_SELF | \ FilesystemIterator :: SKIP_DOTS | \ FilesystemIterator :: UNIX_PATHS ) ; $ iterator_iterator = new \ RecursiveIteratorIterator ( $ dir_iterator , \ RecursiveIteratorIterator :: CHILD_FIRST ) ; $ regex_iterator = new \ RegexIterator ( $ iterator_iterator , $ regex , \ RegexIterator :: MATCH , \ RegexIterator :: USE_KEY ) ; return $ regex_iterator ; }
Regex directory iterator.

@since 140417 Initial release.

@param string $dir   Path to a directory.
@param string $regex Regular expression.

@return \RegexIterator
Regex directory iterator .