Checks whether the value matches the regular expression.

@param string $name
@param string $value
@param string $pattern
@throws InvalidAttribute
489620
private function validateValue(string $name, string $value, string $pattern): void
    {
        if (!preg_match("#^$pattern$#", $value)) {
            throw InvalidAttribute::badFormat($name, $value, $pattern);
        }
    }
933804
public void setRegExp(final String pattern,
                          final String invalidCharactersInNameErrorMessage,
                          final String invalidCharacterTypedMessage) {
        regExp = RegExp.compile(pattern);
        this.invalidCharactersInNameErrorMessage = invalidCharactersInNameErrorMessage;
        this.invalidCharacterTypedMessage = invalidCharacterTypedMessage;
    }
775479
protected static boolean isNameValid(String name) {
    Preconditions.checkNotNull(name);
    name = name.toLowerCase();
    return VALID_DB_TABLE_NAME_PATTERN_1.matcher(name).matches()
        && VALID_DB_TABLE_NAME_PATTERN_2.matcher(name).matches();
  }
1253091
private static function getHtmlAttribute(string $name, $value): string
    {
        if (!self::isset($value)) {
            return '';
        }

        if ($value === true) {
            return $name;
        }

        if (is_array($value)) {
            $value = self::convertAttributeArrayValue($name, $value);
        }

        return sprintf('%s="%s"', $name, static::escape((string) $value));
    }
464906
public function push($name, $value = null)
    {
        switch ($name) {
        case 'name':
            $this->setName($value);
            break;
        case 'type':
            break;
        case 'value':
            $this->setValue($value, true);
            break;
        case 'required':
            $this->required = true;
            break;
        case 'pattern':
        case 'regex':
            $this->regex = $value;
            $this->attributes['pattern'] = $value;
            break;
        case 'minlength':
            $this->minlength = $value;
            $this->attributes['minlength'] = $value;
            break;
        case 'maxlength':
            $this->maxlength = $value;
            $this->attributes['maxlength'] = $value;
            break;
        case 'mapping':
            $this->mapping = $value;
            break;
        case 'prettyname':
            $this->prettyname = $value;
            break;
        case 'readonly':
            $this->readonly = true;
            $this->attributes['readonly'] = 'readonly';
            break;
        default:
            if (preg_match('#^([a-z0-9_-]+)$#mUsi', $name)) {
                if (null !== $value) {
                    $this->setAttribute($name, $value);
                } else {
                    $this->setAttribute($name, $name);
                }
            }
        }
    }
946749
protected function validateConfig($name, $value)
	{
		switch ($name)
		{
			case 'offset':
			case 'totalItems':
				// make sure it's an integer
				if ($value != intval($value))
				{
					$value = 0;
				}
				// and that it's within bounds
				$value = max(0, $value);
			break;

			// validate integer values
			case 'current':
			case 'limit':
			case 'totalPages':
			case 'numberOfLinks':
			case 'uriSegment':
				// make sure it's an integer
				if ($value != intval($value))
				{
					$value = 1;
				}
				// and that it's within bounds
				$value = max(1, $value);
			break;

			// validate booleans
			case 'showFirst':
			case 'showLast':
				if ( ! is_bool($value))
				{
					$value = (bool) $value;
				}
			break;

			// possible alignment values
			case 'align':
				if ( ! in_array($value = strtolower($value), array('left', 'center', 'right')))
				{
					$value = 'center';
				}
			break;

			// validate the link offset, and adjust if needed
			case 'linkOffset':
				// make sure we have a fraction between 0 and 1
				if ($value > 1)
				{
					$value = $value / 100;
				}

				// and that it's within bounds
				$value = max(0.01, min($value, 0.99));
			break;
		}

		return $value;
	}
1031458
private function validateName($name)
    {
        if (strlen($name) < 1) {
            throw new \InvalidArgumentException('The name cannot be empty');
        }

        // Name attribute is a token as per spec in RFC 2616
        if (preg_match('/[\x00-\x20\x22\x28-\x29\x2C\x2F\x3A-\x40\x5B-\x5D\x7B\x7D\x7F]/', $name)) {
            throw new \InvalidArgumentException(sprintf('The cookie name "%s" contains invalid characters.', $name));
        }
    }
905702
public function setAttribute($name, $value)
    {
        if ($this->hasAttribute($name)) {
            $this->$name = $value;
        } else {
            throw new InvalidParamException(get_class($this).' '.\Yii::t('skeeks/cms',
                    'has no attribute named "{name}".', ['name' => $name]));
        }
    }
829117
private function match($exp, $pattern, $value) {
		$pattern = strtolower($pattern);
		$value = strtolower($value);
		switch ($exp) {
			case '=' :
				return ($value === $pattern);
			case '!=' :
				return ($value !== $pattern);
			case '^=' :
				return preg_match("/^" . preg_quote($pattern, '/') . "/", $value);
			case '$=' :
				return preg_match("/" . preg_quote($pattern, '/') . "$/", $value);
			case '*=' :
				if ($pattern [0] == '/') {
					return preg_match($pattern, $value);
				}
				return preg_match("/" . $pattern . "/i", $value);
		}
		return FALSE;
	}
1227392
public function inputFormat($value, $name)
    {
        if (!is_bool($value)) {
            throw new InvalidArgumentException('The value to inputFormat function must be boolean.');
        }
        $value = (int) $value;

        return '000000000000000000000000000000000000000000000000000000000000000' . $value;
    }
825363
public function hasAttributeValue($name, $value = null)
    {
        if (!$this->hasAttribute($name)) {
            return false;
        }
        return (empty($value))? true : (array_search($value, $this->getArrayAttribute($name)) !== false);
    }
495681
def check_match(self, name):
        
        return any(pattern.match(name) for pattern in self.patterns)
219855
def match(pattern, name):
    # type: (Text, Text) -> bool
    
    try:
        re_pat = _PATTERN_CACHE[(pattern, True)]
    except KeyError:
        res = "(?ms)" + _translate(pattern) + r'\Z'
        _PATTERN_CACHE[(pattern, True)] = re_pat = re.compile(res)
    return re_pat.match(name) is not None
901256
public function setPattern($name, $pattern)
    {
        if (is_array($pattern)) {
            return $this->provideHelper($this->patternName($name), $pattern);
        }

        $this->registerHelper('patterns.'.$name, $pattern);

        return $this->provideHelper($this->patternName($name), [
            'pattern',
            'patterns.'.$name,
            function ($proceed, $pattern) {
                return function () use ($proceed, $pattern) {
                    $args = func_get_args();
                    array_unshift($args, $pattern);

                    return call_user_func_array($proceed, $args);
                };
            },
        ]);
    }
213933
public Pattern attribute(final String name, final Object value) {
        return attribute(name, String.valueOf(value));
    }
757055
private function validateTagName(string $name): void
    {
        if (! preg_match('/^' . StandardTagFactory::REGEX_TAGNAME . '$/u', $name)) {
            throw new \InvalidArgumentException(
                'The tag name "' . $name . '" is not wellformed. Tags may only consist of letters, underscores, '
                . 'hyphens and backslashes.'
            );
        }
    }
710906
protected function isValid($value)
    {
        $result = preg_match($this->options['regularExpression'], $value);
        if ($result === 0) {
            $this->addError('The given subject did not match the pattern. Got: %1$s', 1221565130, [$value]);
        }
        if ($result === false) {
            throw new InvalidValidationOptionsException('regularExpression "' . $this->options['regularExpression'] . '" in RegularExpressionValidator contained an error.', 1298273089);
        }
    }