classes/Route.php
protected static function compilePatternAsRegex($pattern, $rules=[], $extract_params=true){

      return '#^'.preg_replace_callback('#:([a-zA-Z]\w*)#',$extract_params
        // Extract named parameters
        ? function($g) use (&$rules){
            return '(?<' . $g[1] . '>' . (isset($rules[$g[1]])?$rules[$g[1]]:'[^/]+') .')';
          }
        // Optimized for matching
        : function($g) use (&$rules){
            return isset($rules[$g[1]]) ? $rules[$g[1]] : '[^/]+';
          },
      str_replace(['.',')','*'],['\.',')?','.+'],$pattern)).'$#';
    }
protected static function compilePatternAsRegex($pattern, $rules=[], $extract_params=true){

      return '#^'.preg_replace_callback('#:([a-zA-Z]\w*)#',$extract_params
        // Extract named parameters
        ? function($g) use (&$rules){
            return '(?<' . $g[1] . '>' . (isset($rules[$g[1]])?$rules[$g[1]]:'[^/]+') .')';
          }
        // Optimized for matching
        : function($g) use (&$rules){
            return isset($rules[$g[1]]) ? $rules[$g[1]] : '[^/]+';
          },
      str_replace(['.',')','*'],['\.',')?','.+'],$pattern)).'$#';
    }
protected static function compilePatternAsRegex ( $ pattern , $ rules = [ ] , $ extract_params = true ) { return '#^' . preg_replace_callback ( '#:([a-zA-Z]\w*)#' , $ extract_params // Extract named parameters ? function ( $ g ) use ( & $ rules ) { return '(?<' . $ g [ 1 ] . '>' . ( isset ( $ rules [ $ g [ 1 ] ] ) ? $ rules [ $ g [ 1 ] ] : '[^/]+' ) . ')' ; } // Optimized for matching : function ( $ g ) use ( & $ rules ) { return isset ( $ rules [ $ g [ 1 ] ] ) ? $ rules [ $ g [ 1 ] ] : '[^/]+' ; } , str_replace ( [ '.' , ')' , '*' ] , [ '\.' , ')?' , '.+' ] , $ pattern ) ) . '$#' ; }
Compile an URL schema to a PREG regular expression.
@param  string $pattern The URL schema.
@return string The compiled PREG RegEx.
Compile an URL schema to a PREG regular expression .