Datasheet
Method Description
int end(int group) Returns the index that is one past the ending position of a spec-
ified capturing group.
boolean find() Returns true if a match is found starting at one index immedi-
ately after the previous match, or at the beginning of the line if
the matcher has been reset.
boolean find(int start) Resets the matcher and attempts to match the pattern against
the input text starting at position
start. Returns true if a
match is found.
boolean hitEnd() Returns true if the end of input was reached by the last match.
boolean requireEnd() Returns true if more input could turn a positive match into a
negative match.
boolean lookingAt() Returns true if the pattern matches, but does not require that
the pattern has to match the input text completely.
boolean matches() Returns true if the pattern matches the string. The pattern must
describe the entire string for this method to return true. For
partial matching, use
find() or lookingAt().
Pattern pattern() Returns a reference to the pattern currently being used on the
matcher.
Matcher reset() Resets the matcher’s state completely.
Matcher reset Resets the matcher’s state completely and sets new input to
(CharSequence input) input.
int start() Returns the starting position of the previous match.
int start(int group) Returns the starting position of a specified capturing group.
Matcher usePattern Sets a new pattern to use for matching. The current position in
(Pattern newPattern) the input is not changed.
String group() Returns a string containing the contents of the previous match.
String group(int group) Returns a string containing the contents of a specific matched
group. The 0-th group is always the entire expression.
int groupCount() Returns the number of capturing groups in the matcher’s
pattern.
Matcher region(int start, Returns a Matcher that is confined to a substring of the string
int end) to search. The caret and dollar sign meta-characters will match
at the beginning and end of the defined region.
int regionEnd() Returns the end index (one past the last position actually
checked) of the currently defined region.
int regionStart() Returns the start index of the currently defined region.
Table continued on following page
67
Chapter 1: Key Java Language Features and Libraries
05_777106 ch01.qxp 11/28/06 10:43 PM Page 67