A pattern which matches <code>pattern</code> as many times as possible
but at least <code>min</code> times and at most <code>max</code> times.
@param pattern
@param min
@param max
@return
962842
public static Pattern repeat(Pattern pattern, int min, int max)
   {
      if (pattern == null)
      {
         throw new IllegalArgumentException("Pattern can not be null");
      }
      return new RepeatPattern(pattern, min, max);
   }
746793
@Requires("isValidPattern(pattern)")
  public R get(String pattern) {
    String canon = pattern.replace('/', '.');
    boolean exact = !canon.endsWith(".*");
    if (!exact) {
      canon = canon.substring(0, canon.length() - 2);
    }

    String[] parts = canon.split("\\.");
    TernaryNode current = root;
    R best = null;
    for (int i = 0; i < parts.length; ++i) {
      TernaryNode next = current.children.get(parts[i]);
      if (next == null) {
        break;
      }
      if (next.rule != null) {
        if (next.exact) {
          if (exact && i == parts.length - 1) {
            best = next.rule;
          }
        } else {
          best = next.rule;
        }
      }
      current = next;
    }
    return best;
  }
605272
public ValidatorBuilderInteger<PARENT> range(int min, int max) {

    return range(new Range<>(Integer.valueOf(min), Integer.valueOf(max)));
  }
1260769
public boolean find(Pattern pattern)
    {
        matcher.usePattern(pattern);
        int start = matcher.regionStart();
        if (matcher.find())
        {
            stack.add(new MatchResultImpl(matcher));
            matcher.region(matcher.end(), matcher.regionEnd());
            return true;
        }
        else
        {
            return false;
        }
    }
1098653
public static boolean isValidPattern(String pattern) {
    if (pattern == null) {
      return false;
    }
    String canon = pattern.replace('/', '.');
    return ClassName.isQualifiedName(canon)
        || ClassName.isStarQualifiedName(canon);
  }
891906
protected org.apache.log4j.helpers.PatternParser createPatternParser(final String pattern) {
		return new FoundationLoggingPatternParser(pattern);
	}
995272
public static final String convertPattern(String pattern) {
        if (pattern == null) {
            return null;
        }
        else {
            String convertedPattern = pattern;
            for (PatternConverter converter : PATTERN_CONVERTERS) {
                convertedPattern = converter.convert(convertedPattern);
            }

            return convertedPattern;
        }
    }
1006722
@Deprecated
  public static Pattern some(int min, int max, CharPredicate predicate) {
    return times(min, max, predicate);
  }
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);
        }

    }
576040
public static List<Match> search(Match m, Pattern pattern)
	{
		assert pattern.getStartingClass().isAssignableFrom(m.get(0).getModelInterface());

		return searchRecursive(m, pattern.getConstraints(), 0);
	}
815085
public static @Nonnull Predicate nameContains(final @Nonnull Pattern pattern) {
        return new Predicate() {
            @Override
            public boolean isValid(@Nonnull ProcessThread<?, ?, ?> thread) {
                return pattern.matcher(thread.getName()).find();
            }
        };
    }
1261214
public Set<String> keys(String pattern) {
        Set<String> result = new TreeSet<String>();
        for (String key : keys()) {
            if (key.matches(pattern)) result.add(key);
        }
        return result;
    }
1032917
private ProcPattern createPattern(Pattern pattern) {
        if (pattern.isEmpty()) {
            throw new IllegalStateException("Pattern elements list can't be empty.");
        }

        List<ProcPatternElement> elements = new ArrayList<ProcPatternElement>();
        for (PatternElement element : pattern.getElements()) {
            elements.add(patternElementFactory.create(element));
        }
        return new ProcPattern(elements);
    }
901396
public static Pattern compile(String pattern) throws IllegalArgumentException {
        if (pattern == null) {
            throw new IllegalArgumentException("Pattern can not be null");
        }

        if (pattern.startsWith("/") && pattern.endsWith("/") && pattern.length() > 1) {
            // This is a regular expression
            // So create matcher as is
            try {
                return Pattern.compile(pattern.substring(1, pattern.length() - 1));
            } catch (PatternSyntaxException e) {
                throw new IllegalArgumentException("Pattern contains an invalid expression", e);
            }
        }

        StringBuilder rEPattern = new StringBuilder("^");

        for (int i = 0; i < pattern.length(); i++) {
            if (pattern.charAt(i) == '*')
                rEPattern.append('.');
            if (pattern.charAt(i) == '?') {
                rEPattern.append('.');
            } else {
                rEPattern.append(pattern.charAt(i));
            }
        }

        rEPattern.append("$");

        try {
            return Pattern.compile(rEPattern.toString());
        } catch (PatternSyntaxException e) {
            throw new IllegalArgumentException("Pattern contains an invalid expression", e);
        }
    }
546948
public static <T extends Comparable<T>> Matcher<T> between(T min, T max) {
        return allOf(greaterThan(min), lessThan(max));
    }
1105029
public ScanParams match(final String pattern) {
    params.put(MATCH, ByteBuffer.wrap(SafeEncoder.encode(pattern)));
    return this;
  }
503202
public ValidatorBuilderDouble<PARENT> range(double min, double max) {

    return range(new Range<>(Double.valueOf(min), Double.valueOf(max)));
  }