Params match regex
@param string $param
@param string $regex
@return Route
435130
public function with(string $param, string $regex): Route{
		$this->params[$param] = str_replace('(', '(?:', $regex);
		return $this;
	}
704064
protected function parse($pattern, $route, $params)
    {
        $pattern = ltrim($pattern, '/');
        if (preg_match_all(self::REGEX, $pattern, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
            $regex = '~^';
            $variables = [];
            $offset = 0;
            $i = 1;
            foreach ($matches as $match) {
                if ($match[0][1] > $offset) {
                    $regex .= preg_quote(substr($pattern, $offset, $match[0][1] - $offset), '~');
                }
                $variables['d' . $i] = $match[1][0];
                $_regex = isset($match[2][0]) ? $match[2][0] : self::DEFAULT_REGEX;
                $regex .= "(?P<d{$i}>$_regex)";
                $offset = $match[0][1] + strlen($match[0][0]);
                $i++;
            }

            if ($offset != strlen($pattern)) {
                $regex .= preg_quote(substr($pattern, $offset), '~');
            }
            $regex .= '$~';
            $this->_routes['var'][$regex] = [$route, $params, $variables];
        } else {
            $this->_routes['static'][$pattern] = [$route, $params];
        }
    }
360577
protected function findRealPathFiles(string $regex, string $path) {
		if(!is_dir($path))
			return null;
				
		$files = $this->findFilesAsSplFileInfo($regex, $path);
		$result = [];
		
		foreach ($files as $item) {
			
			if($item instanceof SplFileInfo)
				$result[] = $item->getRealPath();			
		}
		
		return !empty($result) ? $result : null;
	}
811563
public static function custom($check, $regex = null)
    {
        if ($regex === null) {
            static::$errors[] = 'You must define a regular expression for Validation::custom()';

            return false;
        }

        return static::_check($check, $regex);
    }
1262431
private function match(string $url, Route $route) : array
    {
        $regexp = $this->routeRegexp($route);

        if (preg_match_all('`^' . $regexp . '$`', $url, $matches, PREG_SET_ORDER)) {
            // remove all numeric matches
            $matches = array_diff_key($matches[0], range(0, count($matches[0])));

            // control query string
            if ($route->getUserInputs()) {
                foreach ($route->getUserInputs() as $querystring) {
                    $method = self::request()->getMethod() == 'POST' ? 'getPostOrQuery' : 'getQuery';
                    $value = self::request()->$method($querystring->getName(), $querystring->getType());

                    if (is_null($value) && $querystring->isMandatory()) {
                        return [false, null, $regexp];
                    }

                    if (!is_null($value)) {
                        $matches[$querystring->getName()] = $value;
                    }
                }
            }

            // control conditions
            if ($route->getConditions()) {
                foreach ($route->getConditions() as $condition) {
                    if (!$condition($matches)) {
                        return [false, null, $regexp];
                    }
                }
            }

            return [true, $matches, $regexp];
        }

        return [false, null, $regexp];
    }
742683
protected function _parseLink($url, $regex) {
		$context = stream_context_create(
			['http' => ['header' => 'Connection: close']]);
		$content = file_get_contents($url, false, $context);
		if (!$content) {
			return false;
		}

		$source = preg_replace('/[^(\x20-\x7F)]*/', '', $content);

		if (preg_match('~' . $regex . '~imu', $source, $match)) {
			$this->_match = $match;
			return true;
		}

		return false;
	}
403372
function paramsParser(url, rule) {
    var matches = rule.regexp.exec(url).slice(1);
    var keys = rule.keys;
    var params = {};

    for (var i = 0; i < keys.length; i++) {
      params[keys[i]] = matches[i];
    }

    return params;
  }
170387
public PactDslRequestWithPath matchQuery(String parameter, String regex, List<String> example) {
        requestMatchers.addCategory("query").addRule(parameter, new RegexMatcher(regex));
        query.put(parameter, example);
        return this;
    }
815527
public function match($method, $url)
	{
		$params = array();

		foreach ($this->routes as $name => $route)
		{
			if ($route->isMatch($method, $url))
			{
				$params = $route->getMatchedParams();
				break;
			}
		}

		return $params;
	}
1130499
public function url($uri,$param=[])
    {
        $list=Lists::get();
        if($this->get_index($uri,$list)===false){
            $url=$uri;
        }else{
            $url=$this->return_rule($list,$param);
        }
        return urldecode($url);
    }
1238287
public PactDslRequestWithPath matchQuery(String parameter, String regex) {
        return matchQuery(parameter, regex, new Generex(regex).random());
    }
877834
private function execute($regex, $data)
    {
        $matches = [];

        preg_match($regex, (string)$data, $matches);

        return $matches;
    }
103190
private function matchRoute(string $route, string $url, &$matches, $value = null)
    {
        switch ($this->getParsingMode($route)) {
            case self::MODE_REGEX:
                // Evaluate & remove first match (full route)
                $matched    = preg_match(self::buildRegex($route, !is_null($value)), $url, $matches);
                array_shift($matches);
                break;

            case self::MODE_STRING:
                // final route
                if (is_null($value)) {
                    $matched = $route === $url;
                    $matches = [];

                    // route prefix
                } else {
                    $matched = empty($route) ? empty($url) : strpos($url, $route) === 0;
                    $matches = [str_replace($route, '', $url)];
                }
                break;
        }

        // Route matches
        if (is_null($value)) {
            return $matched;
        }

        // value is sub-routes array
        $sub_routes = !is_callable($value) && is_array($value);
        return $matched && $sub_routes;
    }
718602
public static Predicate<String> matchesRegex(final String regex) {
		final Pattern pattern = Pattern.compile(regex);
		return matchesRegex(pattern);
	}
1125474
public function addRule($regex, $target = null, $params = null)
    {
        $this->rules[] = array($regex, $target, $params);

        return $this;
    }
994291
public function match($regex)
    {
        $matches = preg_match($regex, $this->value);
        $message = ['%s {{does not match|matches}} the regular expression %s', $this->value, $regex];
        $this->assert((!empty($matches)), $message);

        return $this;
    }
868189
public function read($folders = array(), Route $value = null, $regex = '') {

        if (is_null($value)) {

            $value = new Route();

        }

        // if the first 'folder' is empty is removed
        while (!empty($folders) && empty($folders[0])) {

            array_shift($folders);

        }

        // if the 'folder' array is empty, the route has been fully analyzed
        // this is the exit condition from the recursive loop.
        if (empty($folders)) {

            return '^'.$regex.'[\/]?$';

        } else {

            // The first element of the array 'folders' is taken in order to be analyzed
            $folder  = array_shift($folders);

            // All the parameters of the route must be json strings
            $decoded = json_decode($folder, true);

            if (!is_null($decoded) && is_array($decoded)) {

                $param_regex = '';

                $param_required = false;

                /* All the folders can include more than one parameter
                 * Eg: /service_name/{'param1': 'regex1', 'param2': 'regex2'}/
                 *     /calendar/{'ux_timestamp*': '\d{10}', 'microseconds': '\d{4}'}/
                 *
                 * The '*' at the end of the paramerter name implies that the parameter is required
                 * This example can be read as a calendar service that accepts both
                 * timestamps in unix or javascript format.
                 *
                 * This is the reason of the following 'foreach'
                 */
                foreach ($decoded as $key => $string) {

                    $this->logger->debug("Route parser - parameter key: $key");

                    $this->logger->debug("Route parser - parameter string: $string");

                    /* The key and the regex of every paramater is passed to the 'param'
                     * method which will build an appropriate regular expression and will understand
                     * if the parameter is required and will build the Route query object
                     */
                    $param_regex .= $this->param($key, $string, $value);

                    if ($value->isQueryRequired($key)) {
                        $param_required = true;
                    }

                    $this->logger->debug("Route parser - parameter regex: $param_regex");

                }
                // Once the parameter is analyzed, the result is passed to the next iteration
                return $this->read(
                    $folders,
                    $value,
                    $regex.'(?:\/'.$param_regex.')'.(($param_required) ? '{1}' : '?')
                );

            } else {
                // if the element is not a json string, I assume it's the service name
                $value->addService($folder);

                return $this->read(
                    $folders,
                    $value,
                    $regex.'\/'.$folder
                );

            }

        }

    }