Validates an attribite format with a ree hand regular expression.

@param attributeName attribute to validate.
@param pattern regexp pattern which must match  the value.
547686
protected static ValidationBuilder validateRegexpOf(String attributeName, String pattern) {
        return ModelDelegate.validateRegexpOf(modelClass(), attributeName, pattern);
    }
220644
protected function validate( $attribute, $rule )
	{
		list( $rule, $parameters ) = $this->parseRule( $rule );

		if ( $rule == '' )
		{
			return;
		}

		// First we will get the correct keys for the given attribute in case the field is nested in
		// an array. Then we determine if the given rule accepts other field names as parameters.
		// If so, we will replace any asterisks found in the parameters with the correct keys.
		if ( ( $keys = $this->getExplicitKeys( $attribute ) ) && $this->dependsOnOtherFields( $rule ) )
		{
			$parameters = $this->replaceAsterisksInParameters( $parameters, $keys );
		}

		// We will get the value for the given attribute from the array of data and then
		// verify that the attribute is indeed validatable. Unless the rule implies
		// that the attribute is required, rules are not run for missing values.
		$value = $this->getValue( $attribute );

		$validatable = $this->isValidatable( $rule, $attribute, $value );

		$method = "validate{$rule}";

		if ( $validatable && !$this->$method( $attribute, $value, $parameters, $this ) )
		{
			$this->addFailure( $attribute, $rule, $parameters );
		}
	}
139751
public TextInputDialogBuilder setValidationPattern(final Pattern pattern, final String errorMessage) {
        return setValidator(new TextInputDialogResultValidator() {
            @Override
            public String validate(String content) {
                Matcher matcher = pattern.matcher(content);
                if(!matcher.matches()) {
                    if(errorMessage == null) {
                        return "Invalid input";
                    }
                    return errorMessage;
                }
                return null;
            }
        });
    }
972473
public void setRegexPatternSets(java.util.Collection<RegexPatternSetSummary> regexPatternSets) {
        if (regexPatternSets == null) {
            this.regexPatternSets = null;
            return;
        }

        this.regexPatternSets = new java.util.ArrayList<RegexPatternSetSummary>(regexPatternSets);
    }
933804
public void setRegExp(final String pattern,
                          final String invalidCharactersInNameErrorMessage,
                          final String invalidCharacterTypedMessage) {
        regExp = RegExp.compile(pattern);
        this.invalidCharactersInNameErrorMessage = invalidCharactersInNameErrorMessage;
        this.invalidCharacterTypedMessage = invalidCharacterTypedMessage;
    }
1267852
private void required(String attributeName, String atttributValue) throws ApplicationException {
	if (atttributValue == null)
	    throw new ApplicationException("invalid attribute constelation for the tag ftp", "attribute [" + attributeName + "] is required, if action is [" + action + "]");
    }
912622
private boolean matchLemmaRegexp(AnalyzedTokenReadings aToken,
      Pattern pattern) {
    boolean matches = false;
    for (AnalyzedToken analyzedToken : aToken) {
      final String posTag = analyzedToken.getLemma();
      if (posTag != null) {
        final Matcher m = pattern.matcher(posTag);
        if (m.matches()) {
          matches = true;
          break;
        }
      }
    }
    return matches;
  }
393352
function (name, pattern) {

            var regex,
                ret;

            pattern = pattern || ".*";

            regex = new RegExp(pattern);

            logger.debug("PluginMatcher matchPattern testing [" + name + "] against regex [" + pattern + "]");

            ret = regex.exec(name);

            return ret !== null;

        }
598421
@Override
    public final void applyPattern(String pattern)
    {

        if (hasRegistry())
        {
            super.applyPattern(pattern);
            toPattern = super.toPattern();
            return;
        }

        ArrayList<Format> foundFormats = new ArrayList<Format>();
        ArrayList<String> foundDescriptions = new ArrayList<String>();
        StringBuilder stripCustom = new StringBuilder(pattern.length());

        ParsePosition pos = new ParsePosition(0);
        char[] c = pattern.toCharArray();
        int fmtCount = 0;

        while (pos.getIndex() < pattern.length())
        {

            char charType = c[pos.getIndex()];

            if (QUOTE == charType)
            {

                appendQuotedString(pattern, pos, stripCustom, true);
                continue;

            }

            if (START_FE == charType)
            {

                fmtCount++;
                seekNonWs(pattern, pos);
                int start = pos.getIndex();
                int index = readArgumentIndex(pattern, next(pos));
                stripCustom.append(START_FE).append(index);
                seekNonWs(pattern, pos);
                Format format = null;
                String formatDescription = null;
                if (c[pos.getIndex()] == START_FMT)
                {
                    formatDescription = parseFormatDescription(pattern, next(pos));
                    format = getFormat(formatDescription);
                    if (format == null)
                    {
                        stripCustom.append(START_FMT).append(formatDescription);
                    }
                }
                foundFormats.add(format);
                foundDescriptions.add(format == null ? null : formatDescription);

                Preconditions.checkState(foundFormats.size() == fmtCount);
                Preconditions.checkState(foundDescriptions.size() == fmtCount);

                if (c[pos.getIndex()] != END_FE)
                {
                    throw new IllegalArgumentException("Unreadable format element at position " + start);
                }

            }

            //$FALL-THROUGH$
            stripCustom.append(c[pos.getIndex()]);
            next(pos);

        }

        super.applyPattern(stripCustom.toString());

        toPattern = insertFormats(super.toPattern(), foundDescriptions);

        if (containsElements(foundFormats))
        {
            Format[] origFormats = getFormats();
            // only loop over what we know we have, as MessageFormat on Java 1.3
            // seems to provide an extra format element:
            Iterator<Format> it = foundFormats.iterator();
            for (int i = 0; it.hasNext(); i++)
            {
                Format f = it.next();
                if (f != null)
                {
                    origFormats[i] = f;
                }
            }
            super.setFormats(origFormats);
        }

    }
1214640
@GwtIncompatible("java.util.regex.Pattern")
  public void matches(Pattern regex) {
    if (!regex.matcher(actual()).matches()) {
      failWithActual("expected to match", regex);
    }
  }
902131
public CharSequence matchesPattern(final CharSequence input, final String pattern, final String message) {
        if (!Pattern.matches(pattern, input)) {
            fail(message);
        }
        return input;
    }
672164
java.util.regex.Pattern getPattern(
            @Nonnull AnnotationValue<?> annotationMetadata,
            boolean isOptional) {
        final Optional<String> regexp = annotationMetadata.get("regexp", String.class);
        final String pattern;

        if (isOptional) {
            pattern = regexp.orElse(".*");
        } else {
            pattern = regexp
                    .orElseThrow(() -> new ValidationException("No pattern specified"));
        }

        final Pattern.Flag[] flags = annotationMetadata.get("flags", Pattern.Flag[].class).orElse(ZERO_FLAGS);
        if (isOptional && pattern.equals(".*") && flags.length == 0) {
            return null;
        }

        int computedFlag = 0;
        for (Pattern.Flag flag : flags) {
            computedFlag = computedFlag | flag.getValue();
        }

        final PatternKey key = new PatternKey(pattern, computedFlag);
        java.util.regex.Pattern regex = COMPUTED_PATTERNS.get(key);
        if (regex == null) {
            try {
                if (computedFlag != 0) {
                    regex = java.util.regex.Pattern.compile(pattern, computedFlag);
                } else {
                    regex = java.util.regex.Pattern.compile(pattern);
                }
            } catch (PatternSyntaxException e) {
                throw new IllegalArgumentException("Invalid regular expression", e);
            }
            COMPUTED_PATTERNS.put(key, regex);
        }
        return regex;
    }
822949
protected function isValidAttribute($name)
    {
        $pattern = '~^' . self::ATTRIBUTE_REGEX . '$~i';
        $result = @preg_match($pattern, $name);
        return (bool)$result;
    }
889797
public static Expression regexpContains(String expression, String pattern) {
        return regexpContains(x(expression), pattern);
    }
1332366
@Override
	public void waitForNotAttribute(String attributeName, String pattern, long timeout) throws WidgetException {
		waitForAttributePatternMatcher(attributeName, pattern, timeout, false);
	}
12546
public static String convertPatternToPerlRegex(@Nonnull final Pattern pattern) {
		Check.notNull(pattern, "pattern");
		final String modifiers = Flag.convertToModifiers(Flag.parse(pattern.flags()));
		return String.format(PATTERN_TO_REGEX_TEMPLATE, pattern.pattern(), modifiers);
	}
473701
func Pattern(p string) {
	if a, ok := attributeDefinition(); ok {
		if a.Type != nil && a.Type.Kind() != design.StringKind {
			incompatibleAttributeType("pattern", a.Type.Name(), "a string")
		} else {
			_, err := regexp.Compile(p)
			if err != nil {
				dslengine.ReportError("invalid pattern %#v, %s", p, err)
			} else {
				if a.Validation == nil {
					a.Validation = &dslengine.ValidationDefinition{}
				}
				a.Validation.Pattern = p
			}
		}
	}
}