klyn.regex.RegExMatcher.group
method
public native group(index as Int = 0) as String
Description

Returns the text captured by the current match or one of its groups.

Parameters
ParameterDescription
indexZero-based capture-group index. Group 0 is the full match.
Returns

The captured text, or null when an optional group did not participate.

Throws
  • IllegalStateException if no successful match is current.
  • IndexException if the group index is invalid.
Example
matcher = RegEx(r"([A-Za-z]+):(\d+)").matcher("alpha:12")
if matcher.find():
print(matcher.group())   # alpha:12
print(matcher.group(1))  # alpha