Determine if a given string matches a given pattern.

@param  string $pattern
@param  string $value

@return bool
353435
public static function match($pattern, $value)
    {
        if ($pattern == $value) {
            return true;
        }

        $pattern = preg_quote($pattern, '#');
        if ($pattern !== '/') {
            $pattern = str_replace('\*', '.*', $pattern) . '\z';
        } else {
            $pattern = '/$';
        }

        return (bool) preg_match('#^' . $pattern . '#', $value);
    }
1053150
public function matches(string $pattern): bool
	{
		return (bool) preg_match('#' . $pattern . '#', $this->request->getPath());
	}
1145374
protected function _validate($value)
    {
        $value = trim($value);
        $pattern = '/^[a-f0-9]{32}$/';
        return (is_string($value) && preg_match($pattern, $value) == 1);
    }
924394
public function validate(string $value)
    {
        if (!$value || preg_match($this->pattern, $value)) {
            return;
        }

        $this->error['regex'] = [];
    }
262738
public static function isBinaryValue($value)
    {
        /*
         * Not a string?
         * Nothing to do
         */
        if (!is_string($value)) {
            return false;
        }

        $pattern = self::$patterns['binaryValue'];

        return (bool)preg_match($pattern, $value);
    }
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;
  }
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;
        }
    }
1355082
static public function regex($value, $pattern, $message = null, $propertyPath = null)
        {
            static::string($value, $message);

            if ( ! preg_match($pattern, $value)) {
                $message = $message ?: sprintf(
                    'Value "%s" does not match expression.',
                    static::stringify($value)
                );

                throw static::createException($value, $message, static::INVALID_REGEX , $propertyPath, array('pattern' => $pattern));
            }
        }
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);
            }
        }
    }
1239213
public static boolean matches(String[] patterns, String value) {
        for (int i = 0; i < patterns.length; i++) {
            String pattern = patterns[i];
            if (pattern.equals(value)) {
                return true;
            }
            if (pattern.endsWith("*")) {
                if (value.startsWith(pattern.substring(0, pattern.length() - 1))) {
                    return true;
                }
            }
            if (pattern.startsWith("*")) {
                if (value.endsWith(pattern.substring(1))) {
                    return true;
                }
            }
        }
        return false;
    }
401494
public function matches($pattern)
    {
        $this->isString();

        $this->doCheck(function ($value) use ($pattern) {
            $this->throwExceptionIfFalse(
                preg_match($pattern, $value),
                'String "%s" does not match "%s"', $value, $pattern
            );
        });

        return $this;
    }
767865
public static boolean matches(String pattern, String value) {
        Pattern p = Pattern.compile(pattern);
        Matcher m = p.matcher(value);
        return m.matches();
    }
125357
public function contains($pattern, $regexp = FALSE)
  {
    if(empty($pattern))
    {
      return TRUE;
    }

    if($regexp)
    {
      return (preg_match("/" . $pattern . "/i", $this->string)) ? TRUE : FALSE;
    }
    else
    {
      return (stristr($this->string, $pattern) !== FALSE) ? TRUE : FALSE;
    }
  }
841269
protected function _validate($value)
    {
        $value = trim(str_replace('\\', '/', $value));
        return (is_string($value) && (preg_match(self::PATTERN, $value)) == 1);
    }
1299612
public function validate(string $value)
    {
        if (!$value || $this->value === $value) {
            return;
        }

        $this->error['match'] = [$this->value];
    }
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);
    }
371390
public function matchesPattern($event, $pattern)
    {
        if ($pattern === '*') {
            return true;
        }

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

        return fnmatch($pattern, $event);
    }