fun main(args: Array<String>) {
val inputString = "John 9731879"
val match = Regex("(\\w+) (\\d+)").find(inputString)!! // 1
val (name, phone) = match.destructured // 2
println(name) // John // value of the first group matched by \w+
println(phone) // 9731879 // value of the second group matched by \d+
// group with the zero index is the whole substring matched by the regular expression
println(match.groupValues) // [John 9731879, John, 9731879]
val numberedGroupValues = match.destructured.toList() // 3
// destructured group values only contain values of the groups, excluding the zeroth group.
println(numberedGroupValues) // [John, 9731879]
}