findAll
fun
findAll
(
input
:
CharSequence
,
startIndex
:
Int
=
0
)
:
Sequence
<
MatchResult
>
(Common source) (JVM source) (Native source)
fun
findAll
(
input
:
CharSequence
,
startIndex
:
Int
=
0
)
:
<ERROR CLASS>
<
<ERROR CLASS>
>
(source)
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
}
Exceptions
IndexOutOfBoundsException
- if
startIndex
is less than zero or greater than the length of the
input
char sequence.