budkit/budkit-framework · Route.php
php logo
protected function isServerMatchRegex($server, $name, $regex)
    {
        $value = isset($server[$name])
            ? $server[$name]
            : '';
        $regex = "#(?P<{$name}>{$regex})#";
        preg_match($regex, $value, $matches);

        return $matches;
    }
Similar code snippets
1.
budkit/budkit-framework · Route.php
Match rating: 68.3% · See similar code snippets
php logo
protected function isServerMatch($server)
    {
        foreach ($this->server as $name => $regex) {
            $matches = $this->isServerMatchRegex($server, $name, $regex);
            if (!$matches) {
                return $this->fail(self::FAILED_SERVER, " ($name)");
            }
            $this->matches[$name] = $matches[$name];
        }

        return $this->pass();
    }
2.
PHPixie/Route · Matcher.php
Match rating: 64.57% · See similar code snippets
php logo
protected function matchRegex($regex, $string)
    {
        if(preg_match($regex, $string, $matches) !== 1) {
            return null;
        }
        
        array_shift($matches);
        return $matches;
    }
3.
oliwierptak/Everon1 · Regex.php
Match rating: 61.83% · See similar code snippets
php logo
protected function regexValidate($name, $regex)
    {
        $match = (@preg_match($regex, null));
        if ($match === false) {
            throw new Exception\Helper('Invalid regex for: "%s"', $name);
        }
    }
4.
InterNations/http-mock · RegexMatcher.php
Match rating: 61.41% · See similar code snippets
php logo
protected function createMatcher()
    {
        $regex = $this->regex;

        return static function ($value) use ($regex) {
            return (bool) preg_match($regex, $value);
        };
    }
5.
hunzhiwange/framework · Dispatch.php
Match rating: 60.98% · See similar code snippets
php logo
protected function prepareRegexForWildcard(string $regex): string
    {
        $regex = preg_quote($regex, '/');
        $regex = '/^'.str_replace('\*', '(\S*)', $regex).'$/';

        return $regex;
    }
6.
samurai-fw/samurai · GlobExpression.php
Match rating: 60.96% · See similar code snippets
php logo
public function getRegexPattern()
    {
        $regex = preg_quote($this->value, '/');
        $regex = substr($regex, -1) !== '*' ? $regex . '$' : $regex;
        $regex = preg_replace('/\\\\\\*/', '.*?', $regex);
        return "/^{$regex}/";
    }
7.
PHPixie/Route · Matcher.php
Match rating: 60.88% · See similar code snippets
php logo
public function match($pattern, $string)
    {
        $regex = '#^'.$pattern->regex().'$#i';
        if(($matches = $this->matchRegex($regex, $string)) === null) {
            return null;
        }
        
        return $this->mapParameters($pattern, $matches);
    }
8.
phmLabs/Smoke · RegExExistsRule.php
Match rating: 60.48% · See similar code snippets
php logo
public function init(array $regExs)
    {
        $regExArray = array();

        foreach ($regExs as $regEx) {
            if (array_key_exists('regex', $regEx)) {
                $isRegex = $regEx['isRegex'] == 'on';
                $regExArray[] = ['pattern' => $regEx['regex'], 'isRegEx' => $isRegex];
            } else {
                $regExArray[] = $regEx;
            }
        }

        $this->regExs = $regExArray;
    }
9.
vitodtagliente/pure-routing · Route.php
Match rating: 60.47% · See similar code snippets
php logo
private function match_regex($value, $pattern, $rules = array())
    {
        $pieces = explode(':', $pattern);
        if(count($pieces) <= 1)
            return false;

        $regex = $pieces[1];

        if (array_key_exists($regex, $rules)) {
            $regex = $rules[$regex];
        }

        // ritorna vero se il valore
        // rispetta l'espressione regolare
        return preg_match( "/$regex/", $value );
    }
10.
greg-md/php-router · RouteUtils.php
Match rating: 60.39% · See similar code snippets
php logo
private static function paramFetchRegex(string $regex): string
    {
        if ($regex === '*') {
            return '.+?';
        }

        $regex = Regex::disableGroups($regex);

        if ($regex[-1] == '+' or $regex[-1] == '*') {
            $regex .= '?';
        }

        return $regex;
    }