Set a constraint to a token in the route pattern.

@param string $token
@param string $regex

@return self
190573
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;
    }
1179845
public function setMatch(string $match) : self
    {
        if (substr($match, 0, 1) == '^' || substr($match, -1) == '$') {
            throw new \InvalidArgumentException(
                sprintf("Can't set start & end line on match for '%s'", $match)
            );
        }

        $this->match = $match;

        return $this;
    }
226138
public function assert(string $key, string $regex): self
    {
        return $this->setRequirement($key, $regex);
    }
1005604
public function add_tag( $tag = '', $regex = '', $force = false ) {
		if ( ! isset( $this->rewrite_tag[ $tag ] ) || isset( $this->rewrite_tag[ $tag ] ) && true === $force ) {
			$this->rewrite_tag[ $tag ] = $regex;
		}
		return $this;
	}
434082
private function createConstraint($token, $column, $operator, $value, $filter)
    {
        if (!$this->isFilterable($filter, $value)) {
            return $this;
        }

        $this->append(sprintf('%s %s %s %s ', $token, $this->quote($column), $operator, $value));
        return $this;
    }
435130
public function with(string $param, string $regex): Route{
		$this->params[$param] = str_replace('(', '(?:', $regex);
		return $this;
	}
333121
public function setRegexp($pattern)
    {
        $regexp = new RegularExpression();
        $regexp->setPattern($pattern);
        $this->_regexps[] = $regexp;
    }
313921
private function doTransitionFromG() : self
    {
        if ($this->getToken() === Grammar::T_N) {
            $this
                ->setState(self::STATE_Y)
                ->addPosition(1);
            return $this;
        }

        if ($this->getToken() === Grammar::T_M) {
            $this
                ->setState(self::STATE_G)
                ->addPosition(1)
                ->addTokenValue(Grammar::T_M);
            return $this;
        }

        $this->setState(self::STATE_F);
        return $this;
    }
1202003
public function setToken($token)
    {
        $this->token = $token;
        $this->username = '';
        $this->password = '';
        $this->accessToken = '';
        return $this;
    }
1332048
public function notRegexp($pattern, $msg)
    {
        if(preg_match($pattern, (string)$this->_value)) {
            $this->_errors[] = $msg;
        }
        return $this;
    }
916458
public function addValidator($slug,$regex){
		$this->regex=null;
		$this->validators[(string)$slug]=(string)$regex;
		return $this;
	}
1132889
public function moveToToken(Token $token) {

      if (!$token->isValid()) {
        $this->setValid(false);
        return new Token();
      }

      $tokenIndex = $token->getIndex();


      foreach ($this->collection as $index => $collectionToken) {
        if ($collectionToken->getIndex() === $tokenIndex) {
          $this->setPosition($index);
          return $collectionToken;
        }
      }

      $this->setValid(false);
      return new Token();
    }
717178
private function replaceTokensWithRegexCaptureGroups($regex)
    {
        $tokenRegex = self::TOKEN_REGEX;

        return preg_replace_callback(
            self::PLACEHOLDER_REGEXP,
            array($this, 'replaceTokenWithRegexCaptureGroup'),
            $regex
        );
    }
505154
public function whereNotRegex($field, $regex, $flags = '')
    {
        $this->_filters[] = [$field => ['$not' => new Regex($regex, $flags)]];

        return $this;
    }
1080129
public RouteMatcher postWithRegEx(String regex, Handler<HttpServerRequest> handler) {
		addRegEx(regex, handler, postBindings);
		return this;
	}
1243490
public function regex(string $regex) : Text
    {
        return $this->pipe(
            self::predicate(
                function ($value) use ($regex) {
                    return preg_match($regex, $value) === 1;
                },
                "does not match $regex"
            )
        );
    }
881810
public function trim($regex = Strings::TRIM_CHARACTERS)
    {
        $this->_string = Strings::trim($this->_string, $regex);
        $this->_direction = null;

        return $this;
    }