Returns the contents of the parenthesized subgroups of a match, counting parentheses from left to right and starting from 1. Group 0 always refers to the entire match. For example, if the pattern
foo(\d+)
is used to extract a match from the input
abfoo123
, then
group(0)
will return
foo123
and
group(1)
will return
123
.
group(2)
will return
null
because there is only one subgroup in the original pattern.
@param group The pattern subgroup to return.
@return A string containing the indicated pattern subgroup. Group0 always refers to the entire match. If a group was never matched, it returns null. This is not to be confused with a group matching the null string, which will return a String of length 0.