asGroup

fun Regex.asGroup(name: String? = null): Regex

Wraps this pattern in a capturing group, named name if given (as a Java (?<name>...) named group), otherwise anonymous. Named groups are how SyntaxColoring tells which token kind matched.