Try to match against regex, this is the last resort, usually we first
try to find a direct match and look in the cache as well. But if no
match has been found yet this is the last try.

@return bool
@throws MethodNotAllowed
@throws NotFound
541263
protected function matchRegex()
    {
        // Match request against route table
        foreach ($this->routes as $route => $endpoint) {
            $result = $this->routeParser->parse($route);

            // Get regex
            $regex = $result[0];
            // Get param names
            $paramNames = $result[1];

            if (preg_match($regex, $this->requestUri, $matches)) {
                // Check if endpoint class exists
                if (!$this->endpointExists($endpoint)) {
                    // Endpoint class not found
                    throw new NotFound();
                } elseif (!$this->endpointMethodExists($endpoint, $this->requestMethod)) {
                    // Route found but method can't be found
                    throw new MethodNotAllowed();
                }

                // Set matched route
                $this->matchedRoute = $route;
                // Set matched endpoint
                $this->matchedEndpoint = $endpoint;
                // Set matched request method
                $this->matchedMethod = $this->requestMethod;

                // Remove all slashes from param values/matches
                $matches = array_diff($matches, ['/']);

                // Remove first value in the matches array since it wont be used
                array_shift($matches);

                // Loop through all params and match them with values and save the result
                // to the params array
                foreach ($paramNames as $key => $name) {
                    $this->params[$name] = (isset($matches[$key])) ? $matches[$key]: null;
                }

                // Match found, add it to the cache for later use
                $this->addToCache($this->requestUri);

                // Time to stop looking for more matches
                return true;
            }
        }

        return false;
    }
725085
public function validate()
    {
        $attributes = static::getMapper()->getAttributes();
        $keys = $this->isFresh() ? array_keys($attributes) : array_keys($this->dirty);

        foreach ($keys as $key) {
            $attribute = $attributes[$key];

            if ($attribute['auto_generate'] && $this->isFresh()) {
                continue;
            }

            $value = $this->get($key);
            $type = Type::factory($attribute['type']);

            if ($type->isNull($value)) {
                if (!$attribute['allow_null']) {
                    throw new Exception\UnexpectedPropertyValueException(sprintf('%s: Property "%s", not allow null', get_class($this), $key));
                }
            } else {
                if ($attribute['regexp'] && !preg_match($attribute['regexp'], $value)) {
                    throw new Exception\UnexpectedPropertyValueException(sprintf('%s: Property "%s", mismatching pattern %s', get_class($this), $key, $attribute['regexp']));
                }

                if (!$attribute['allow_tags'] && is_string($value) && \Owl\str_has_tags($value)) {
                    throw new Exception\UnexpectedPropertyValueException(sprintf('%s: Property "%s", cannot contain tags', get_class($this), $key));
                }

                try {
                    $type->validateValue($value, $attribute);
                } catch (\Exception $ex) {
                    $message = sprintf('%s: Property "%s", %s', get_class($this), $key, $ex->getMessage());
                    throw new Exception\UnexpectedPropertyValueException($message, 0, $ex);
                }
            }
        }

        return true;
    }
989321
private function backtrack(): bool
    {
        $found = false;

        do {
            $last = \array_pop($this->trace);

            if ($last instanceof Entry) {
                $found = $this->grammar->fetch($last->getRule()) instanceof Alternation;
            } elseif ($last instanceof Escape) {
                $found = $this->grammar->fetch($last->getRule()) instanceof Repetition;
            } elseif ($last instanceof Token) {
                if (! $this->stream->prev()) {
                    return false;
                }
            }
        } while (0 < \count($this->trace) && $found === false);

        if ($found === false) {
            return false;
        }

        $this->todo = $last->getTodo();
        $this->todo[] = new Entry($last->getRule(), $last->getData() + 1);

        return true;
    }
294599
public function match($URL, $method='get'){
      $method = strtolower($method);

      // * is an http method wildcard
      if (empty($this->methods[$method]) && empty($this->methods['*'])) return false;

      return (bool) (
        $this->dynamic
           ? preg_match($this->matcher_pattern, '/'.trim($URL,'/'))
           : rtrim($URL,'/') == rtrim($this->pattern,'/')
      );
    }
410323
public function resolve() {
        $return = false;
        $match = $this->match();

        if (!$match) {            
            $target = $this->getDefaultRoute();
            if ($target) {
                $match = ['target' => $target];
            }                            
        }


        if (substr(Utils::get('name', $match, ''),0,7) =='plugin:') {
            Application::getInstance()->preparePlugin($match['name']);
        }
        
        
        if (is_array($match) && array_key_exists('target', $match)) {
            
            $target = $match['target'];
            
            $return = ['target'=>$target, 'match'=>$match, 'application' => $this->getApplicationName()];
            
            if (array_key_exists('class', $target)) {
                $return['type'] = 'class';
            } elseif (array_key_exists('controller', $target)) {
                $return['type'] = 'controller';
            } elseif (array_key_exists('view', $target)) {
                $return['type'] = 'view';
            } elseif (array_key_exists('eval', $target)) {
                $return['type'] = 'eval';
            } else { 
                $return = ['success'=>false, 'msg' =>  "Target undefined",'code'=>404, 'info'=> $match];           
            }
        } else {
            $return = ['success'=>false, 'msg' =>  "Target not found",'code'=>404, 'info'=> $match];
        }
        
        return $return;        
    }
341258
public function containsString()
    {
        if (strpos($this->data[0], $this->data[1]) === false) {
            throw new DidNotMatchException();
        }

        return $this->data[0];
    }
1085804
protected function matchDirect()
    {
        // Create variable used to keep track on progress
        $endpoint = false;

        // check without a trailing slash
        if (isset($this->routes[$this->requestUri])) {
            $endpoint = $this->routes[$this->requestUri];
        } else {
            // no match return false
            return false;
        }

        // check if endpoint class exists
        if (!$this->endpointExists($endpoint)) {
            throw new NotFound();
        } elseif (!$this->endpointMethodExists($endpoint, $this->requestMethod)) {
            // route found but method can't be found
            throw new MethodNotAllowed();
        }

        // found a direct match, set needed properties
        $this->matchedRoute = $this->requestUri;
        $this->matchedEndpoint = $endpoint;
        $this->matchedMethod = $this->requestMethod;

        // we found our match, stop looking for more
        return true;
    }
111047
public function matchesRequest()
    {
        $noAttachments = Collection::make($this->event->get('attachments'))->isEmpty();

        return $noAttachments && (! is_null($this->event->get('recipient')) && ! is_null($this->event->get('serviceUrl')));
    }
33738
protected function _checkRequestMethods()
    {
        $action = $this->_action();
        $apiConfig = $action->getConfig('api');

        if (!isset($apiConfig['methods'])) {
            return false;
        }

        $request = $this->_request();
        foreach ($apiConfig['methods'] as $method) {
            if ($request->is($method)) {
                return true;
            }
        }

        throw new MethodNotAllowedException();
    }
1269227
public function not_pattern()
    {
        $patterns = func_get_args();

        foreach (func_get_args() as $pattern) {
            $this->not_patterns[] = $this->pattern_to_regex($pattern);
        }

        return $this;
    }
1354221
public function attemptToFormatAccruedDigits()
    {
        foreach ($this->possibleFormats as $numberFormat) {
            $m = new Matcher($numberFormat->getPattern(), $this->nationalNumber);
            if ($m->matches()) {
                $nationalPrefixSeparatorsMatcher = new Matcher(self::$nationalPrefixSeparatorsPattern, $numberFormat->getNationalPrefixFormattingRule());
                $this->shouldAddSpaceAfterNationalPrefix = $nationalPrefixSeparatorsMatcher->find();
                $formattedNumber = $m->replaceAll($numberFormat->getFormat());
                return $this->appendNationalNumber($formattedNumber);
            }
        }
        return '';
    }
1263557
public function checkPassword(): bool
    {
        if (!isset($this->regex)) {
            return true;
        }

        return filter_var($this->password, FILTER_VALIDATE_REGEXP, [
            'options' => [
                'regexp' => $this->regex
            ]
        ]);
    }
1363019
public function match()
    {
        $elements = $this->getHostElements();

        return isset($elements[$this->elementNumber - 1]) ? $elements[$this->elementNumber - 1] : false;
    }
737892
protected function validateMethod()
    {
        if (! in_array(strtoupper($this->option('method')), $methods = array_merge(Router::$verbs, ['ANY']))) {
            throw new MethodNotAllowedException($methods);
        }
    }
51140
public function search()
	{
		preg_match_all('/\[[^\]]*\]/', $this->str, $this->matches);		

		// Format matches
		if(!empty($this->matches))
		{
			$this->matches = $this->matches[0];
			$this->format();
		}

		return $this;
	}
789951
public function matchesRequest()
    {
        $hasImages = ! Collection::make($this->event->get('attachments'))->isEmpty();

        return parent::matchesRequest() && $hasImages;
    }
1072193
protected function currentUrlMatches()
    {
        if ($this->url() == Request::url()) { // If URLs are equal, always return true
            return true;
        }

        if ($this->activeUrlPattern) { // If pattern was set, see if it matches
            $pattern = ltrim(preg_replace('/\/\*/', '(/.*)?', $this->activeUrlPattern), '/');
            return preg_match("@^{$pattern}\z@", Request::path());
        }

        return false; // No match
    }