Method that tries to match the given pattern to the given value.

@param string $value Value where the pattern match will be performed.
@param string $pattern Pattern to match.

@return bool True if pattern matched the value, otherwise false.
974119
private function matchValue($value, $pattern)
    {
        // basic check
        if ($value == $pattern) {
            return true;
        }

        // simple check in case of optional param
        if ($pattern == '?') {
            return true;
        }

        // simple match in case pattern is just "*"
        if ($pattern == '*' && $value != '') {
            return true;
        }

        // more complex match in case when wildcard is part of a larger match
        $pattern = str_replace('*', '(.+)', $pattern);

        // regex match
        if (strpos($pattern, '(') !== false || strpos($pattern, '[') !== false || strpos($pattern, '\\') !== false) {
            return preg_match('#^' . $pattern . '$#', $value);
        }

        return false;
    }
1229864
public static boolean safeRegexMatch(String pattern, String value) {
        if (StringUtils.isNotBlank(pattern)) {
            if (value == null) {
                return false;
            } else {
                try {
                    return Pattern.matches(pattern, value);
                } catch (PatternSyntaxException ex) {
                    return false;
                }
            }
        } else {
            return false;
        }
    }
1231765
public static function isDomainname($value)
    {
        if (strlen($value) > 253) {
            return false;
        }

        $pattern = "/^(?!\-)(?:[a-zA-Z\d\-]{0,62}[a-zA-Z\d]\.){1,126}(?!\d+)[a-zA-Z\d]{1,63}$/";

        return (boolean) preg_match($pattern, $value);
    }
1352631
public static function is($pattern, $value)
    {
        $patterns = Arr::wrap($pattern);

        if (empty($patterns)) {
            return false;
        }

        foreach ($patterns as $pattern) {
            // If the given value is an exact match we can of course return true right
            // from the beginning. Otherwise, we will translate asterisks and do an
            // actual pattern match against the two strings to see if they match.
            if ($pattern == $value) {
                return true;
            }

            $pattern = preg_quote($pattern, '#');

            // Asterisks are translated into zero-or-more regular expression wildcards
            // to make it convenient to check if the strings starts with the given
            // pattern such as "library/*", making any string check convenient.
            $pattern = str_replace('\*', '.*', $pattern);

            if (preg_match('#^'.$pattern.'\z#u', $value) === 1) {
                return true;
            }
        }

        return false;
    }
857229
public function isValid($value)
    {
        $this->_setValue($value);

        if (!is_string($value)) {
            return false;
        }

        return @preg_match(self::LASTMOD_REGEX, $value) == 1;
    }
636215
public static function matchPattern(string $pattern, string $fileName): bool
    {
        $replaceMap = [
            '*' => '.*',
            '.' => '\.',
            '+' => '.+',
            '/' => '\/',
        ];

        $pattern = str_replace(array_keys($replaceMap), array_values($replaceMap), $pattern);
        $pattern = '/' . $pattern . '/i';

        if (preg_match($pattern, $fileName)) {
            return true;
        }

        return false;
    }
996337
private function filter(&$value)
    {
        if (isset($this->patterns[$value])) {
            $value = $this->patterns[$value];
        } else {
            // Test that pattern is a valid REGEXP pattern
            ErrorHandler::start();
            $this->pattern = (string) $value;
            $status        = preg_match($this->pattern, "Test");
            $error         = ErrorHandler::stop();
        
            if (false === $status) {
                throw new Exception\InvalidArgumentException("Internal error parsing the pattern '{$this->value}'", 0, $error);
            }
        }
    }
389495
public static function reg_match($object, $value): bool
    {
        if (!Any::isLine($object)) {
            return false;
        }

        if (Str::likeEmpty($object)) {
            return true;
        }

        // what the f*ck? -> return preg_match($value, $object) > 0;
        return (bool)preg_match($value, $object);
    }
33835
private function matchPattern($pathName, $pattern)
    {
        if ($pattern[0] !== '/') {
            $pattern = '**/' . $pattern;
        }

        if (\fnmatch($pattern, $pathName)) {
            return true;
        }

        return false;
    }
1360053
protected function apply_value_pattern( $output, $value ) {
		if ( isset( $output['value_pattern'] ) && ! empty( $output['value_pattern'] ) && is_string( $output['value_pattern'] ) ) {
			if ( ! is_array( $value ) ) {
				$value = str_replace( '$', $value, $output['value_pattern'] );
			}
			if ( is_array( $value ) ) {
				foreach ( array_keys( $value ) as $value_k ) {
					if ( is_array( $value[ $value_k ] ) ) {
						continue;
					}
					if ( isset( $output['choice'] ) ) {
						if ( $output['choice'] === $value_k ) {
							$value[ $output['choice'] ] = str_replace( '$', $value[ $output['choice'] ], $output['value_pattern'] );
						}
						continue;
					}
					$value[ $value_k ] = str_replace( '$', $value[ $value_k ], $output['value_pattern'] );
				}
			}
			$value = $this->apply_pattern_replace( $output, $value );
		}
		return $value;
	}
1185729
public function matchUrl($pattern)
    {
        if ($this->matchValue($this->getUrl(), $pattern)) {
            return $this->getUrl();
        }

        return false;
    }
23953
protected function validatorValue($value)
    {
        if ($value === null) {
            return $this->allowEmpty;
        }

        if (preg_match($this->pattern, $value)) {
            return true;
        }

        return false;
    }
10375
protected function checkValidity($value) : bool
    {
        if (preg_match(static::$regex, $value)) {
            return true;
        } elseif ('' === $value) {
            return true;
        } else {
            return false;
        }
    }
1159397
public function validate($value)
    {
        $value = trim($value);
        $pattern = '/^[a-z]{2}-[A-Z]{2}$/';
        return (empty($value))
                || (is_string($value) && preg_match($pattern, $value) == 1);
    }
1145374
protected function _validate($value)
    {
        $value = trim($value);
        $pattern = '/^[a-f0-9]{32}$/';
        return (is_string($value) && preg_match($pattern, $value) == 1);
    }
155840
public static function checkRegexPattern($pattern)
  {
    $check = @preg_match($pattern, "anything"); // thats the easy way to check a pattern ;)
    if (is_integer($check) == false) return false;
    else return true;
  }
371390
public function matchesPattern($event, $pattern)
    {
        if ($pattern === '*') {
            return true;
        }

        if ($event == $pattern) {
            return true;
        }

        return fnmatch($pattern, $event);
    }