greg-md/php-router · RouteUtils.php
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;
    }
Similar code snippets
1.
samurai-fw/samurai · GlobExpression.php
Match rating: 77.14% · 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}/";
    }
2.
hunzhiwange/framework · Dispatch.php
Match rating: 71.44% · See similar code snippets
php logo
protected function prepareRegexForWildcard(string $regex): string
    {
        $regex = preg_quote($regex, '/');
        $regex = '/^'.str_replace('\*', '(\S*)', $regex).'$/';

        return $regex;
    }
3.
fortrabbit/datafilter · Basic.php
Match rating: 71.32% · See similar code snippets
php logo
public static function ruleRegex($regex)
    {
        $args = func_get_args();
        $regex = join(':', $args);

        /*not in format "/../<modifier>", "#..#<modifier>"  nor "~..~<modifier>" */
        if (!preg_match('/^([\/#~]).+\1[msugex]*$/', $regex)) {
            $regex = '/'. stripslashes($regex). '/';
        }

        return function ($input) use ($regex) {
            return preg_match($regex, $input);
        };
    }
4.
Match rating: 70.47% · See similar code snippets
php logo
private function _getLikeRegex($string)
  {
    $regex = preg_quote($string, '/');
    $regex = preg_replace('/(?<!\\\\)%/', '.*?', $regex);
    $regex = str_replace('\\\\%', '\\%', $regex);
    return '/^' . $regex . '$/';
  }
5.
rollerworks/app-sectioning · SectionConfiguration.php
Match rating: 70.41% · See similar code snippets
php logo
private static function stripDelimiters(?string $regex): ?string
    {
        if (null === $regex || mb_strlen($regex) < 2) {
            return $regex;
        }

        return mb_substr($regex, 1, mb_strrpos($regex, $regex[0], 0, 'UTF-8') - 1, 'UTF-8');
    }
6.
hunzhiwange/framework · Validator.php
Match rating: 70.32% · See similar code snippets
php logo
protected function prepareRegexForWildcard(string $regex, bool $strict = true): string
    {
        $regex = preg_quote($regex, '/');
        $regex = '/^'.str_replace('\*', '(\S+)', $regex).($strict ? '$' : '').'/';

        return $regex;
    }
7.
InterNations/http-mock · RegexMatcher.php
Match rating: 69.54% · See similar code snippets
php logo
protected function createMatcher()
    {
        $regex = $this->regex;

        return static function ($value) use ($regex) {
            return (bool) preg_match($regex, $value);
        };
    }
8.
fuelphp/routing · Parameter.php
Match rating: 68.64% · See similar code snippets
php logo
public function getRegex()
	{
		$regex = '(?P<'.$this->name.'>'.$this->regex.')';

		if ($this->optional)
		{
			$regex = '(?:'.$regex.')?';
		}

		return $regex;
	}
9.
atkrad/data-tables · Search.php
Match rating: 68.58% · See similar code snippets
php logo
public function setRegex($regex)
    {
        if ($regex === 'false') {
            $this->regex = false;

            return $this;
        }
        $this->regex = true;

        return $this;
    }
10.
nicoSWD/php-rule-parser · Tokenizer.php
Match rating: 68.34% · See similar code snippets
php logo
private function getRegex(): string
    {
        if (!$this->regex) {
            $regex = [];

            foreach ($this->getQueue() as $token) {
                $regex[] = "(?<$token->class>$token->regex)";
            }

            $this->regex = '~(' . implode('|', $regex) . ')~As';
        }

        return $this->regex;
    }