private function uriTemplateToRegex($uri)
    {
        preg_match_all('#((?<!\?):[^/]+|{[^0-9][^}]*}|\(.+?\))#', $uri, $params, PREG_PATTERN_ORDER);
        $return = array($uri);
        if (isset($params[1])) {
            foreach ($params[1] as $index => $param) {
                if (substr($param, 0, 1) == ':') {
                    $return[] = substr($param, 1);
                } elseif (substr($param, 0, 1) == '{' && substr($param, -1, 1) == '}') {
                    $return[] = substr($param, 1, -1);
                } else {
                    $return[] = $index;
                }
            }
        }

        $return[0] = preg_replace('#((?<!\?):[^(/]+|{[^0-9][^}]*})#', '([^/]+)', $return[0]);

        return $return;
    }
private function uriTemplateToRegex($uri)
    {
        preg_match_all('#((?<!\?):[^/]+|{[^0-9][^}]*}|\(.+?\))#', $uri, $params, PREG_PATTERN_ORDER);
        $return = array($uri);
        if (isset($params[1])) {
            foreach ($params[1] as $index => $param) {
                if (substr($param, 0, 1) == ':') {
                    $return[] = substr($param, 1);
                } elseif (substr($param, 0, 1) == '{' && substr($param, -1, 1) == '}') {
                    $return[] = substr($param, 1, -1);
                } else {
                    $return[] = $index;
                }
            }
        }

        $return[0] = preg_replace('#((?<!\?):[^(/]+|{[^0-9][^}]*})#', '([^/]+)', $return[0]);

        return $return;
    }
private function uriTemplateToRegex ( $ uri ) { preg_match_all ( '#((?<!\?):[^/]+|{[^0-9][^}]*}|\(.+?\))#' , $ uri , $ params , PREG_PATTERN_ORDER ) ; $ return = array ( $ uri ) ; if ( isset ( $ params [ 1 ] ) ) { foreach ( $ params [ 1 ] as $ index => $ param ) { if ( substr ( $ param , 0 , 1 ) == ':' ) { $ return [ ] = substr ( $ param , 1 ) ; } elseif ( substr ( $ param , 0 , 1 ) == '{' && substr ( $ param , - 1 , 1 ) == '}' ) { $ return [ ] = substr ( $ param , 1 , - 1 ) ; } else { $ return [ ] = $ index ; } } } $ return [ 0 ] = preg_replace ( '#((?<!\?):[^(/]+|{[^0-9][^}]*})#' , '([^/]+)' , $ return [ 0 ] ) ; return $ return ; }
Turn a URL template into a regular expression
@param  str[] $uri URL template
@return str[] Regular expression and parameter names
Turn a URL template into a regular expression