Sets the regex Pattern this tries to match. Won't do anything until the target is set as well.
@param regex the Pattern this should match
551231
public void setPattern(Pattern regex)
    {
        this.re = regex;

        int memregCount, counterCount, lookaheadCount;
        if ((memregCount = regex.memregs) > 0) {
            MemReg[] memregs = new MemReg[memregCount];
            for (int i = 0; i < memregCount; i++) {
                memregs[i] = new MemReg(-1); //unlikely to SearchEntry, in this case we know memreg indices by definition
            }
            this.memregs = memregs;
        }

        if ((counterCount = regex.counters) > 0) counters = new int[counterCount];

        if ((lookaheadCount = regex.lookaheads) > 0) {
            LAEntry[] lookaheads = new LAEntry[lookaheadCount];
            for (int i = 0; i < lookaheadCount; i++) {
                lookaheads[i] = new LAEntry();
            }
            this.lookaheads = lookaheads;
        }

        this.memregCount = memregCount;
        this.counterCount = counterCount;
        this.lookaheadCount = lookaheadCount;

        first = new SearchEntry();
        defaultEntry = new SearchEntry();
        minQueueLength = regex.stringRepr.length() / 2;  // just evaluation!!!

    }
835789
public static Pattern get(String regex, int flags) {
		final RegexWithFlag regexWithFlag = new RegexWithFlag(regex, flags);

		Pattern pattern = POOL.get(regexWithFlag);
		if (null == pattern) {
			pattern = Pattern.compile(regex, flags);
			POOL.put(regexWithFlag, pattern);
		}
		return pattern;
	}
952384
public void logMatchesFound(String regex){
		if (uniqueTextViews.size() > 0) {
			Log.d(LOG_TAG, " There are only " + uniqueTextViews.size() + " matches of '" + regex + "'");
		}
		else if(webElements.size() > 0){
			Log.d(LOG_TAG, " There are only " + webElements.size() + " matches of '" + regex + "'");
		}
		uniqueTextViews.clear();
		webElements.clear();
	}
430475
public static <T extends CharSequence> T validateMatchRegex(String regex, T value, String errorMsg) throws ValidateException {
		if (false == isMactchRegex(regex, value)) {
			throw new ValidateException(errorMsg);
		}
		return value;
	}
902131
public CharSequence matchesPattern(final CharSequence input, final String pattern, final String message) {
        if (!Pattern.matches(pattern, input)) {
            fail(message);
        }
        return input;
    }
299297
public RouteMatcher putWithRegEx(String regex, Handler<HttpServerRequest> handler) {
		addRegEx(regex, handler, putBindings);
		return this;
	}
181232
public boolean matches(CharacterIterator target, Match match) {
		int start = target.getBeginIndex();
		int end = target.getEndIndex();

		synchronized (this) {
			if (this.operations == null)
				this.prepare();
			if (this.context == null)
				this.context = new Context();
		}
		Context con = null;
		synchronized (this.context) {
			con = this.context.inuse ? new Context() : this.context;
			con.reset(target, start, end, this.numberOfClosures);
		}
		if (match != null) {
			match.setNumberOfGroups(this.nofparen);
			match.setSource(target);
		} else if (this.hasBackReferences) {
			match = new Match();
			match.setNumberOfGroups(this.nofparen);
			// Need not to call setSource() because
			// a caller can not access this match instance.
		}
		con.match = match;

		if (RegularExpression.isSet(this.options, XMLSCHEMA_MODE)) {
			int matchEnd = this.match(con, this.operations, con.start, 1,
					this.options);
			// System.err.println("DEBUG: matchEnd="+matchEnd);
			if (matchEnd == con.limit) {
				if (con.match != null) {
					con.match.setBeginning(0, con.start);
					con.match.setEnd(0, matchEnd);
				}
				con.setInUse(false);
				return true;
			}
			return false;
		}

		/*
		 * The pattern has only fixed string. The engine uses Boyer-Moore.
		 */
		if (this.fixedStringOnly) {
			// System.err.println("DEBUG: fixed-only: "+this.fixedString);
			int o = this.fixedStringTable.matches(target, con.start, con.limit);
			if (o >= 0) {
				if (con.match != null) {
					con.match.setBeginning(0, o);
					con.match.setEnd(0, o + this.fixedString.length());
				}
				con.setInUse(false);
				return true;
			}
			con.setInUse(false);
			return false;
		}

		/*
		 * The pattern contains a fixed string. The engine checks with
		 * Boyer-Moore whether the text contains the fixed string or not. If
		 * not, it return with false.
		 */
		if (this.fixedString != null) {
			int o = this.fixedStringTable.matches(target, con.start, con.limit);
			if (o < 0) {
				// System.err.println("Non-match in fixed-string search.");
				con.setInUse(false);
				return false;
			}
		}

		int limit = con.limit - this.minlength;
		int matchStart;
		int matchEnd = -1;

		/*
		 * Checks whether the expression starts with ".*".
		 */
		if (this.operations != null && this.operations.type == Op.CLOSURE
				&& this.operations.getChild().type == Op.DOT) {
			if (isSet(this.options, SINGLE_LINE)) {
				matchStart = con.start;
				matchEnd = this.match(con, this.operations, con.start, 1,
						this.options);
			} else {
				boolean previousIsEOL = true;
				for (matchStart = con.start; matchStart <= limit; matchStart++) {
					int ch = target.setIndex(matchStart);
					if (isEOLChar(ch)) {
						previousIsEOL = true;
					} else {
						if (previousIsEOL) {
							if (0 <= (matchEnd = this.match(con,
									this.operations, matchStart, 1,
									this.options)))
								break;
						}
						previousIsEOL = false;
					}
				}
			}
		}

		/*
		 * Optimization against the first character.
		 */
		else if (this.firstChar != null) {
			// System.err.println("DEBUG: with firstchar-matching: "+this.firstChar);
			RangeToken range = this.firstChar;
			for (matchStart = con.start; matchStart <= limit; matchStart++) {
				int ch = target.setIndex(matchStart);
				if (REUtil.isHighSurrogate(ch) && matchStart + 1 < con.limit) {
					ch = REUtil.composeFromSurrogates(ch,
							target.setIndex(matchStart + 1));
				}
				if (!range.match(ch)) {
					continue;
				}
				if (0 <= (matchEnd = this.match(con, this.operations,
						matchStart, 1, this.options))) {
					break;
				}
			}
		}

		/*
		 * Straightforward matching.
		 */
		else {
			for (matchStart = con.start; matchStart <= limit; matchStart++) {
				if (0 <= (matchEnd = this.match(con, this.operations,
						matchStart, 1, this.options)))
					break;
			}
		}

		if (matchEnd >= 0) {
			if (con.match != null) {
				con.match.setBeginning(0, matchStart);
				con.match.setEnd(0, matchEnd);
			}
			con.setInUse(false);
			return true;
		} else {
			con.setInUse(false);
			return false;
		}
	}
808324
public static Condition matchText(final String regex) {
    return new Condition("match text") {
      @Override
      public boolean apply(Driver driver, WebElement element) {
        return Html.text.matches(element.getText(), regex);
      }

      @Override
      public String toString() {
        return name + " '" + regex + '\'';
      }
    };
  }
560427
public CollectionAssert allElementsMatch(String regex) {
		isNotNull();
		isNotEmpty();
		for (Object anActual : this.actual) {
			if (anActual == null) {
				failWithMessageRelatedToRegex(regex, anActual);
			}
			String value = anActual.toString();
			if (!value.matches(regex)) {
				failWithMessageRelatedToRegex(regex, value);
			}
		}
		return this;
	}
706295
protected boolean check(String value, String regex) {
		Pattern pattern = Pattern.compile(regex);
		return pattern.matcher(value).matches();
	}
744304
public static List<String> getStringsByRegex(final String text, final String regex) {

    Pattern pattern = Pattern.compile(regex);
    Matcher matcher = pattern.matcher(text);
    List<String> matchedStrings = new ArrayList<String>();
    while (matcher.find()) {
      matchedStrings.add(matcher.group(0));
    }
    return matchedStrings;
  }
586997
public static int preg_match(String regex, String subject) {
        Pattern p = Pattern.compile(regex);
        return preg_match(p, subject);
    }
1184997
public Regex then(Regex regex) {
      if (regex == null) {
         return this;
      }
      return re(this.pattern + regex.pattern);
   }
268841
@Factory
    public static Matcher<Proc> raisesException(String regex) {
        return new Raises(IsThrowable.exception(regex));
    }
1198391
@Nonnull
  public DescribeCommand match(@Nullable String pattern) {
    if (!"*".equals(pattern)) {
      matchOption = Optional.ofNullable(pattern);
      log.info("--match = {}", matchOption.orElse(""));
    }
    return this;
  }
1340698
public void setPattern(String name, Pattern pattern) {
        if (null == pattern) {
            set(name, null);
        } else {
            set(name, pattern.pattern());
        }
    }
911165
public static boolean regexMatch(String input, String regex) {
        return Pattern.compile(regex).matcher(input).matches();
    }