Returns the input subsequence captured by the given group during the previous match operation.
For a matcher m, input sequence s, and group index g, the expressions m.group(
g)
and s.substring(
m.start(
g ),
m.end(
g))
are equivalent.
Capturing groups are indexed from left to right, starting at one. Group zero denotes the entire pattern, so the expression m.group(0)
is equivalent to m.group()
.
If the match was successful but the group specified failed to match any part of the input sequence, then null
is returned. Note that some groups, for example (a*)
, match the empty string. This method will return the empty string when such a group successfully matches the empty string in the input.