splitToSequence
Splits the input CharSequence to a sequence of strings around matches of this regular expression.
Since Kotlin
1.6Parameters
Non-negative value specifying the maximum number of substrings the string can be split to. Zero by default means no limit is set.
Samples
fun main() {
//sampleStart
val colors = "green, red , brown&blue, orange, pink&green"
val regex = "[,\\s]+".toRegex()
val mixedColor = regex.splitToSequence(colors)
.onEach { println(it) }
.firstOrNull { it.contains('&') }
println(mixedColor) // brown&blue
//sampleEnd
}
Splits the input CharSequence to a sequence of strings around matches of this regular expression.
Since Kotlin
1.6Parameters
Non-negative value specifying the maximum number of substrings the string can be split to. Zero by default means no limit is set.
Samples
fun main() {
//sampleStart
val colors = "green, red , brown&blue, orange, pink&green"
val regex = "[,\\s]+".toRegex()
val mixedColor = regex.splitToSequence(colors)
.onEach { println(it) }
.firstOrNull { it.contains('&') }
println(mixedColor) // brown&blue
//sampleEnd
}
Splits the input CharSequence to a sequence of strings around matches of this regular expression.
Since Kotlin
1.6Parameters
Non-negative value specifying the maximum number of substrings the string can be split to. Zero by default means no limit is set.
Samples
fun main() {
//sampleStart
val colors = "green, red , brown&blue, orange, pink&green"
val regex = "[,\\s]+".toRegex()
val mixedColor = regex.splitToSequence(colors)
.onEach { println(it) }
.firstOrNull { it.contains('&') }
println(mixedColor) // brown&blue
//sampleEnd
}
Splits the input CharSequence to a sequence of strings around matches of this regular expression.
Since Kotlin
1.6Parameters
Non-negative value specifying the maximum number of substrings the string can be split to. Zero by default means no limit is set.
Samples
fun main() {
//sampleStart
val colors = "green, red , brown&blue, orange, pink&green"
val regex = "[,\\s]+".toRegex()
val mixedColor = regex.splitToSequence(colors)
.onEach { println(it) }
.firstOrNull { it.contains('&') }
println(mixedColor) // brown&blue
//sampleEnd
}
Splits the input CharSequence to a sequence of strings around matches of this regular expression.
Since Kotlin
1.8Parameters
Non-negative value specifying the maximum number of substrings the string can be split to. Zero by default means no limit is set.
Samples
fun main() {
//sampleStart
val colors = "green, red , brown&blue, orange, pink&green"
val regex = "[,\\s]+".toRegex()
val mixedColor = regex.splitToSequence(colors)
.onEach { println(it) }
.firstOrNull { it.contains('&') }
println(mixedColor) // brown&blue
//sampleEnd
}
Splits the input CharSequence to a sequence of strings around matches of this regular expression.
Since Kotlin
1.8Parameters
Non-negative value specifying the maximum number of substrings the string can be split to. Zero by default means no limit is set.
Samples
fun main() {
//sampleStart
val colors = "green, red , brown&blue, orange, pink&green"
val regex = "[,\\s]+".toRegex()
val mixedColor = regex.splitToSequence(colors)
.onEach { println(it) }
.firstOrNull { it.contains('&') }
println(mixedColor) // brown&blue
//sampleEnd
}