Java Reference
In-Depth Information
Resets this matcher to use a new input sequence. The re-
turned
Matcher
is the one on which the method was invoked.
public Matcher
usePattern(Pattern pattern)
Changes the pattern used by this matcher to be
pattern
. Any
group information is discarded, but the input and append po-
sitions remain the same.
Once a match has been found, the following methods return more in-
formation about the match:
public int
start()
Returns the start index of the previous match.
public int
end()
Returns the index of the last character matched, plus one.
public String
group()
Returns the input subsequence matched by the previous
match; in other words, the substring defined by
start
and
end
.
public int
groupCount()
Returns the number of capturing groups in this matcher's pat-
tern. Group numbers range from zero to one less than this
count.
public String
group(int group)
Returns the input subsequence matched by the given group
in the previous match. Group zero is the entire matched pat-
tern, so
group(0)
is equivalent to
group()
.