splitToSequence

expect fun splitToSequence(input: CharSequence, limit: Int = 0): Sequence<String>(source)

Splits the input CharSequence to a sequence of strings around matches of this regular expression.

Since Kotlin

1.6

Parameters

limit

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
}
actual fun splitToSequence(input: CharSequence, limit: Int = 0): Sequence<String>(source)

Splits the input CharSequence to a sequence of strings around matches of this regular expression.

Since Kotlin

1.6

Parameters

limit

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
}
actual fun splitToSequence(input: CharSequence, limit: Int = 0): Sequence<String>(source)

Splits the input CharSequence to a sequence of strings around matches of this regular expression.

Since Kotlin

1.6

Parameters

limit

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
}
actual fun splitToSequence(input: CharSequence, limit: Int = 0): Sequence<String>(source)

Splits the input CharSequence to a sequence of strings around matches of this regular expression.

Since Kotlin

1.6

Parameters

limit

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
}
actual fun splitToSequence(input: CharSequence, limit: Int = 0): Sequence<String>(source)

Splits the input CharSequence to a sequence of strings around matches of this regular expression.

Since Kotlin

1.8

Parameters

limit

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
}
actual fun splitToSequence(input: CharSequence, limit: Int = 0): Sequence<String>(source)

Splits the input CharSequence to a sequence of strings around matches of this regular expression.

Since Kotlin

1.8

Parameters

limit

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
}