code: public function getDirectoryPattern($directory)
      {
          $pattern = '/^' . str_replace('/', '\\/', $directory) . '/';
          $pattern = str_replace('\\/**\\/', '\\/([^\/]+\\/)*', $pattern);
          $pattern = str_replace('\\/*\\/', '\\/[^\/]+\\/', $pattern);
  
          return $pattern;
      }
docs: Returns a regular expression pattern to match directories.
  
  @param string $directory
  @return string