public boolean matches(String regex) { return Pattern.matches(regex, this); } public static boolean matches(String regex, CharSequence input) { Pattern p = Pattern.compile(regex); Matcher m = p.matcher(input); return m.matches(); } public static Pattern compile(String regex) { return new Pattern(regex, 0); } public Matcher matcher(CharSequence input) { if (!compiled) { synchronized(this) { if (!compiled) compile(); } } Matcher m = new Matcher(this, input); return m; } public boolean matches() { return match(from, ENDANCHOR); } boolean match(int from, int anchor) { this.hitEnd = false; this.requireEnd = false; from = from < 0 ? 0 : from; this.first = from; this.oldLast = oldLast < 0 ? from : oldLast; for (int i = 0; i < groups.length; i++) groups[i] = -1; acceptMode = anchor; boolean result = parentPattern.matchRoot.match(this, from, text); if (!result) this.first = -1; this.oldLast = this.last; return result; } boolean match(Matcher matcher, int i, CharSequence seq) { matcher.last = i; matcher.groups[0] = matcher.first; matcher.groups[1] = matcher.last; return true; }