Checks if a string matches at least one given pattern

@param string|array $patterns
@param string $subject
@param string $matchedPattern
@param bool $caseSensitive

@return bool
333463
public static function strIs($patterns, $subject, &$matchedPattern = '', $caseSensitive = false)
    {
        if (!is_array($patterns)) {
            $patterns = (array) $patterns;
        }

        $lowerSubject = strtolower($subject);

        foreach ($patterns as $pattern) {

            if ($caseSensitive) {
                if (str_is($pattern, $subject)) {
                    $matchedPattern = $pattern;
                    return true;
                }
            } else {
                $lowerPattern = strtolower($pattern);
                if (str_is($lowerPattern, $lowerSubject)) {
                    $matchedPattern = $pattern;
                    return true;
                }
            }

        }

        return false;
    }
490085
public function match($pattern, array $patterns = []) {
        return $this->matcher->match(
            $this->addLeadingSlash($pattern), $this->getPath(), $patterns
        );
    }
191053
public static function replaceFirst(string $subject, string $search, string $replace, bool $caseSensitive = true): string
    {
        $pos = $caseSensitive ? mb_strpos($subject, $search) : mb_stripos($subject, $search);
        if ($pos === false) {
            return $subject;
        }

        return substr_replace($subject, $replace, $pos, mb_strlen($search));
    }
376527
public static <S> boolean the(S subject, Matcher<? super S> criteria) {
        return criteria.matches(subject);
    }
1095018
public static boolean matchAny(final Collection<String> pattern, final String[] candidate, boolean ignoreCase) {

        for (String string: pattern) {
            if (matchAny(string, candidate, ignoreCase)) {
                return true;
            }
        }

        return false;
    }
293733
public static function for($pattern, $replacement, $subject, $limit)
    {
        try {
            list($result, $count) = is_callable($replacement) ?
                static::doReplacementWithCallable($pattern, $replacement, $subject, $limit) :
                static::doReplacement($pattern, $replacement, $subject, $limit);
        } catch (Exception $exception) {
            throw RegexFailed::replace($pattern, $subject, $exception->getMessage());
        }

        if ($result === null) {
            throw RegexFailed::replace($pattern, $subject, static::lastPregError());
        }

        return new static($pattern, $replacement, $subject, $result, $count);
    }
850574
public function matching ($pattern, &$matches = [], $flags = 0, $offset = 0, $start = 0, $end = null) {
		if (is_null($end)) {
			$end = $this->_length;
		}
		return static::Match($pattern, static::Substring($this->_string, $start, $end), $matches, $flags, $offset);
	}
32312
public function match(Subject $subject, string $verb): bool
    {
        return $this->subject->getType() == $subject->getType() &&
            $this->subject->getId() === $subject->getId() &&
            ($this->verbs === null || in_array($verb, $this->verbs, true));
    }
796882
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));
	}
11941
public function nameContains($needle, $caseSensitive = null)
    {
        if ('' === $needle) {
            return true;
        }
        if (null === $caseSensitive) {
            $caseSensitive = false;
        }

        if ($caseSensitive) {
            return false !== mb_strpos($this->name(), $needle);
        }

        return false !== mb_stripos($this->name(), $needle);
    }
427301
public static function removeLast(string $subject, string $search, bool $caseSensitive = true): string
    {
        return static::replaceLast($subject, $search, '', $caseSensitive);
    }
500417
protected boolean matchHeaderPattern(HttpMessage msg, String header, Pattern pattern) {
        if (msg.getResponseHeader().isEmpty()) {
            return false;
        }

        String val = msg.getResponseHeader().getHeader(header);
        if (val == null) {
            return false;
        }

        Matcher matcher = pattern.matcher(val);
        return matcher.find();
    }
751123
public static function isMatch($value, string $pattern): bool
    {
        if (!static::isStringCastable($value)) {
            return false;
        }

        return !!preg_match($pattern, (string) $value);
    }
1046833
protected static function findPatterns($patternString) {
		$patternString = self::sanitizePatternString($patternString);

		$patternRegExp = self::getPatternRegExp();

		return (preg_match_all($patternRegExp, $patternString, $patternsMatches)) ? $patternsMatches[1] : [];
	}
874520
public function hex($subject, string $case = '') : bool
    {
        if ($subject === null) {
            return false;
        }
        switch ($case) {
            case 'lower':
                $v = '' . $subject;
                return $v === '' ? false : !!preg_match('/^[a-f\d]+$/', '' . $v);
            case 'upper':
                $v = '' . $subject;
                return $v === '' ? false : !!preg_match('/^[A-F\d]+$/', '' . $v);
        }
        // Yes, ctype_... returns false on ''.
        return !!ctype_xdigit('' . $subject);
    }
1142530
def is_match(self, subject: Union[Expression, FlatTerm]) -> bool:
        
        try:
            next(self.match(subject))
        except StopIteration:
            return False
        return True
1168107
private static boolean matchesPatternList(final String str, final List<Pattern> patterns) {
        if (patterns != null) {
            for (final Pattern pattern : patterns) {
                if (pattern.matcher(str).matches()) {
                    return true;
                }
            }
        }
        return false;
    }