code: protected function generatePattern($rule)
      {
          $negate = false;
          $pattern = '{';
  
          if (strlen($rule) && $rule[0] === '!') {
              $negate = true;
              $rule = substr($rule, 1);
          }
  
          if (strlen($rule) && $rule[0] === '/') {
              $pattern .= '^/';
              $rule = substr($rule, 1);
          } elseif (strlen($rule) - 1 === strpos($rule, '/')) {
              $pattern .= '/';
              $rule = substr($rule, 0, -1);
          } elseif (false === strpos($rule, '/')) {
              $pattern .= '/';
          }
  
          // remove delimiters as well as caret (^) and dollar sign ($) from the regex
          $pattern .= substr(Finder\Glob::toRegex($rule), 2, -2) . '(?=$|/)';
  
          return array($pattern . '}', $negate, false);
      }
docs: Generates an exclude pattern for filter() from a gitignore rule
  
  @param string $rule An exclude rule in gitignore syntax
  
  @return array An exclude pattern