findAll
Returns a sequence of all occurrences of a regular expression within the input string, beginning at the specified startIndex.
Since Kotlin
1.0Samples
fun main() {
//sampleStart
val text = "Hello Alice. Hello Bob. Hello Eve."
val regex = Regex("Hello (.*?)[.]")
val matches = regex.findAll(text)
val names = matches.map { it.groupValues[1] }.joinToString()
println(names) // Alice, Bob, Eve
//sampleEnd
}Throws
IndexOutOfBoundsException
if startIndex is less than zero or greater than the length of the input char sequence.