fun findAll( input: CharSequence, startIndex: Int = 0 ): Sequence<MatchResult>
fun findAll( input: CharSequence, startIndex: Int ): Sequence<MatchResult>
Returns a sequence of all occurrences of a regular expression within the input string, beginning at the specified startIndex.
fun main(args: Array<String>) {
//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
}
Returns a sequence of all occurrences of a regular expression within the input string, beginning at the specified startIndex.
© 2010–2019 JetBrains s.r.o.
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/-regex/find-all.html