original_string: protected function compile(&$route)
      {
          if ($route['regex']) {
              return $route;
          }
  
          $regex = preg_replace('#[.\+*?[^\]${}=!|:-]#', '\\\\$0', $route['pattern']);
  
          $regex = str_replace(array('(', ')'), array('(?:', ')?'), $regex);
  
          $regex = str_replace(array('<', '>'), array('(?P<', '>.+?)'), $regex);
  
          if ($route['rules']) {
              $search = $replace = array();
              foreach ($route['rules'] as $key => $rule) {
                  $search[] = '<' . $key . '>.+?';
                  $replace[] = '<' . $key . '>' . $rule;
              }
              $regex = str_replace($search, $replace, $regex);
          }
  
          $route['regex'] = '#^' . $regex . '$#uUD';
  
          return $route;
      }
code: protected function compile(&$route)
      {
          if ($route['regex']) {
              return $route;
          }
  
          $regex = preg_replace('#[.\+*?[^\]${}=!|:-]#', '\\\\$0', $route['pattern']);
  
          $regex = str_replace(array('(', ')'), array('(?:', ')?'), $regex);
  
          $regex = str_replace(array('<', '>'), array('(?P<', '>.+?)'), $regex);
  
          if ($route['rules']) {
              $search = $replace = array();
              foreach ($route['rules'] as $key => $rule) {
                  $search[] = '<' . $key . '>.+?';
                  $replace[] = '<' . $key . '>' . $rule;
              }
              $regex = str_replace($search, $replace, $regex);
          }
  
          $route['regex'] = '#^' . $regex . '$#uUD';
  
          return $route;
      }
code_tokens: protected function compile ( & $ route ) { if ( $ route [ 'regex' ] ) { return $ route ; } $ regex = preg_replace ( '#[.\+*?[^\]${}=!|:-]#' , '\\\\$0' , $ route [ 'pattern' ] ) ; $ regex = str_replace ( array ( '(' , ')' ) , array ( '(?:' , ')?' ) , $ regex ) ; $ regex = str_replace ( array ( '<' , '>' ) , array ( '(?P<' , '>.+?)' ) , $ regex ) ; if ( $ route [ 'rules' ] ) { $ search = $ replace = array ( ) ; foreach ( $ route [ 'rules' ] as $ key => $ rule ) { $ search [ ] = '<' . $ key . '>.+?' ; $ replace [ ] = '<' . $ key . '>' . $ rule ; } $ regex = str_replace ( $ search , $ replace , $ regex ) ; } $ route [ 'regex' ] = '#^' . $ regex . '$#uUD' ; return $ route ; }
docstring: Prepare the route pattern to regex
  
  @param  array  $route the route array
  @return array
docstring_tokens: Prepare the route pattern to regex