original_string: private function pattern_to_regex($pattern)
      {
          if (substr($pattern, -1) == '/') {
              $pattern .= '**';
          }
  
          $regex = '|^';
          foreach (explode('/', $pattern) as $i => $piece) {
              if ($i > 0) {
                  $regex .= preg_quote('/', '|');
              }
  
              if ('**' == $piece) {
                  $regex .= '.*';
              } else {
                  $regex .= str_replace(array('?', '*'), array('[^/]', '[^/]*'), $piece);
              }
          }
          $regex .= '$|';
  
          return $regex;
      }
code: private function pattern_to_regex($pattern)
      {
          if (substr($pattern, -1) == '/') {
              $pattern .= '**';
          }
  
          $regex = '|^';
          foreach (explode('/', $pattern) as $i => $piece) {
              if ($i > 0) {
                  $regex .= preg_quote('/', '|');
              }
  
              if ('**' == $piece) {
                  $regex .= '.*';
              } else {
                  $regex .= str_replace(array('?', '*'), array('[^/]', '[^/]*'), $piece);
              }
          }
          $regex .= '$|';
  
          return $regex;
      }
code_tokens: private function pattern_to_regex ( $ pattern ) { if ( substr ( $ pattern , - 1 ) == '/' ) { $ pattern .= '**' ; } $ regex = '|^' ; foreach ( explode ( '/' , $ pattern ) as $ i => $ piece ) { if ( $ i > 0 ) { $ regex .= preg_quote ( '/' , '|' ) ; } if ( '**' == $ piece ) { $ regex .= '.*' ; } else { $ regex .= str_replace ( array ( '?' , '*' ) , array ( '[^/]' , '[^/]*' ) , $ piece ) ; } } $ regex .= '$|' ; return $ regex ; }
docstring: converts ant-pattern to PCRE regex
  
  @param string $pattern
  @return string
docstring_tokens: converts ant - pattern to PCRE regex