src/Route.php
public function setConstraint($token, $regex)
    {
        $initPos = strpos($this->pattern, "{" . $token);

        if ($initPos !== false) {
            $endPos = strpos($this->pattern, "}", $initPos);
            $newPattern = substr_replace($this->pattern, "{" . "$token:$regex" . "}", $initPos, $endPos - $initPos + 1);
            $wildcards = $this->collector->getParser()->getWildcardTokens();
            $newPattern = str_replace(array_keys($wildcards), $wildcards, $newPattern);
            $this->setPatternWithoutReset($newPattern);
        }

        return $this;
    }
public function setConstraint($token, $regex)
    {
        $initPos = strpos($this->pattern, "{" . $token);

        if ($initPos !== false) {
            $endPos = strpos($this->pattern, "}", $initPos);
            $newPattern = substr_replace($this->pattern, "{" . "$token:$regex" . "}", $initPos, $endPos - $initPos + 1);
            $wildcards = $this->collector->getParser()->getWildcardTokens();
            $newPattern = str_replace(array_keys($wildcards), $wildcards, $newPattern);
            $this->setPatternWithoutReset($newPattern);
        }

        return $this;
    }
public function setConstraint ( $ token , $ regex ) { $ initPos = strpos ( $ this -> pattern , "{" . $ token ) ; if ( $ initPos !== false ) { $ endPos = strpos ( $ this -> pattern , "}" , $ initPos ) ; $ newPattern = substr_replace ( $ this -> pattern , "{" . "$token:$regex" . "}" , $ initPos , $ endPos - $ initPos + 1 ) ; $ wildcards = $ this -> collector -> getParser ( ) -> getWildcardTokens ( ) ; $ newPattern = str_replace ( array_keys ( $ wildcards ) , $ wildcards , $ newPattern ) ; $ this -> setPatternWithoutReset ( $ newPattern ) ; } return $ this ; }
Set a constraint to a token in the route pattern.

@param string $token
@param string $regex

@return self
Set a constraint to a token in the route pattern .