TeaLabs/uzi · Str.php
php logo
public function matches($pattern, $caseSensitive = true)
	{
		$regex = $this->toRegex($pattern, ($caseSensitive ? "" : Modifiers::CASELESS ));

		return $regex->matches($this);
	}
Similar code snippets
1.
TeaLabs/uzi · Str.php
Match rating: 64.09% · See similar code snippets
php logo
public function strip($substring = null, $limit = -1, $caseSensitive = true)
	{
		$pattern = $this->regexPatternForStrip($substring, $limit);

		$regex = $this->newRegex(
							"(?:\A{$pattern})|(?:{$pattern}\z)",
							($caseSensitive ? '' : Modifiers::CASELESS)
						);

		return $this->getNew($regex->replace("", $this));
	}
2.
TeaLabs/uzi · Str.php
Match rating: 60.14% · See similar code snippets
php logo
protected function regexPatternForIs($wildcards, $caseSensitive)
	{
		$pattern = Regex::quote($this->str);

		if($wildcards)
			$pattern = str_replace('\*', '.*', $pattern);

		return $this->newRegex('\A'. $pattern . '\z', ($caseSensitive ?'': Modifiers::CASELESS));
	}
3.
PHPixie/Route · Matcher.php
Match rating: 58.68% · 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);
    }
4.
JBZoo/Utils · Str.php
Match rating: 58.44% · See similar code snippets
php logo
public static function like($pattern, $string, $caseSensitive = true): bool
    {
        if ($pattern === $string) {
            return true;
        }

        // Preg flags
        $flags = $caseSensitive ? '' : 'i';

        // Escape any regex special characters
        $pattern = preg_quote($pattern, '#');

        // Unescaped * which is our wildcard character and change it to .*
        $pattern = str_replace('\*', '.*', $pattern);

        return (bool)preg_match('#^' . $pattern . '$#' . $flags, $string);
    }
5.
tomzx/finder · SymfonyFinder.php
Match rating: 58.21% · See similar code snippets
php logo
public function name($pattern)
	{
		$regex = FilenameMatch::translate($pattern);
		$this->names[] = $regex;

		return $this;
	}
6.
tomzx/finder · SymfonyFinder.php
Match rating: 56.78% · See similar code snippets
php logo
public function notName($pattern)
	{
		$regex = FilenameMatch::translate($pattern);
		$this->notNames[] = $regex;

		return $this;
	}
7.
tomzx/finder · SymfonyFinder.php
Match rating: 56.56% · See similar code snippets
php logo
public function notPath($pattern)
	{
		$regex = FilenameMatch::translate($pattern);
		$this->notPaths[] = $regex;

		return $this;
	}
8.
eloquent/pathogen · AbstractPath.php
Match rating: 56.36% · See similar code snippets
php logo
public function matches($pattern, $caseSensitive = null, $flags = null)
    {
        if (null === $caseSensitive) {
            $caseSensitive = false;
        }
        if (null === $flags) {
            $flags = 0;
        }
        if (!$caseSensitive) {
            $flags = $flags | FNM_CASEFOLD;
        }

        return fnmatch($pattern, $this->string(), $flags);
    }
9.
eloquent/pathogen · AbstractPath.php
Match rating: 56.03% · See similar code snippets
php logo
public function nameMatches($pattern, $caseSensitive = null, $flags = null)
    {
        if (null === $caseSensitive) {
            $caseSensitive = false;
        }
        if (null === $flags) {
            $flags = 0;
        }
        if (!$caseSensitive) {
            $flags = $flags | FNM_CASEFOLD;
        }

        return fnmatch($pattern, $this->name(), $flags);
    }
10.
thephpleague/route · Router.php
Match rating: 55.57% · See similar code snippets
php logo
public function addPatternMatcher(string $alias, string $regex) : self
    {
        $pattern = '/{(.+?):' . $alias . '}/';
        $regex   = '{$1:' . $regex . '}';

        $this->patternMatchers[$pattern] = $regex;

        return $this;
    }