String
representing the matched group.
@param groupVar The name of the capturing group in this matcher's pattern
@return the matched group as a String
or null if there is no capturing group in the pattern with the given name
@throws IllegalStateException If no match has yet been attempted, or if the previous match operation failed
For a matcher m with input sequence s, the expressions m.group() and s.substring(m.start(), m.end()) are equivalent.
Note that some patterns, for example a*, match the empty string. This method will return the empty string when the pattern successfully matches the empty string in the input.
@return The (possibly empty) subsequence matched by the previous match,in string form @throws IllegalStateException If no match has yet been attempted, or if the previous match operation failedFor a matcher m with input sequence s, the expressions m.group() and s.substring(m.start(), m.end()) are equivalent.
Note that some patterns, for example a*, match the empty string. This method will return the empty string when the pattern successfully matches the empty string in the input.
@return The (possibly empty) subsequence matched by the previous match,in string form @throws IllegalStateException If no match has yet been attempted, or if the previous match operation failedFor a matcher m with input sequence s, the expressions m.group() and s.substring(m. start(), m.end()) are equivalent.
Note that some patterns, for example a*, match the empty string. This method will return the empty string when the pattern successfully matches the empty string in the input.
@return The (possibly empty) subsequence matched by the previous match,in string form @throws IllegalStateException If no match has yet been attempted, or if the previous match operation failed@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.
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.
|
|
|
|
|
|
|
|
|
|