src/Http/Request/RouteExpression.php
private function compile()
    {
        // replace pseudo {param}:type syntax to valid regex
        if (strpos($this->regex, '}:') !== false) {
            $this->regex = preg_replace('#\{([a-zA-Z0-9_-]+)\}:([a-z]+)#', '(?P<$1>:$2)', $this->expression);
            $this->regex = str_replace(
                array_keys($this->regexExpression),
                array_values($this->regexExpression),
                $this->regex
            );
        }

        // replace pseudo {param} syntax without type to valid regex
        if (strpos($this->regex, '}') !== false) {
            $this->regex = preg_replace('#\{([a-zA-Z_]+)\}#', '(?P<$1>[^\/]+)', $this->regex);
        }

        // allow optional trailing slash at the end
        if (substr($this->regex, -1) !== '/') {
            $this->regex .= '[\/]?';
        }
    }
private function compile()
    {
        // replace pseudo {param}:type syntax to valid regex
        if (strpos($this->regex, '}:') !== false) {
            $this->regex = preg_replace('#\{([a-zA-Z0-9_-]+)\}:([a-z]+)#', '(?P<$1>:$2)', $this->expression);
            $this->regex = str_replace(
                array_keys($this->regexExpression),
                array_values($this->regexExpression),
                $this->regex
            );
        }

        // replace pseudo {param} syntax without type to valid regex
        if (strpos($this->regex, '}') !== false) {
            $this->regex = preg_replace('#\{([a-zA-Z_]+)\}#', '(?P<$1>[^\/]+)', $this->regex);
        }

        // allow optional trailing slash at the end
        if (substr($this->regex, -1) !== '/') {
            $this->regex .= '[\/]?';
        }
    }
private function compile ( ) { // replace pseudo {param}:type syntax to valid regex if ( strpos ( $ this -> regex , '}:' ) !== false ) { $ this -> regex = preg_replace ( '#\{([a-zA-Z0-9_-]+)\}:([a-z]+)#' , '(?P<$1>:$2)' , $ this -> expression ) ; $ this -> regex = str_replace ( array_keys ( $ this -> regexExpression ) , array_values ( $ this -> regexExpression ) , $ this -> regex ) ; } // replace pseudo {param} syntax without type to valid regex if ( strpos ( $ this -> regex , '}' ) !== false ) { $ this -> regex = preg_replace ( '#\{([a-zA-Z_]+)\}#' , '(?P<$1>[^\/]+)' , $ this -> regex ) ; } // allow optional trailing slash at the end if ( substr ( $ this -> regex , - 1 ) !== '/' ) { $ this -> regex .= '[\/]?' ; } }
Compile expression to valid regex
Compile expression to valid regex