fork download
  1. import java.util.*
  2.  
  3. fun main(args: Array<String>) {
  4. val text = "red 1 green 3 blue"
  5. println(text.split(Regex("red|green|blue")))
  6. println( text.split(Regex("red|green|blue")).filter{ !it.isBlank() } )
  7.  
  8. }
Success #stdin #stdout 0.09s 34944KB
stdin
Standard input is empty
stdout
[,  1 ,  3 , ]
[ 1 ,  3 ]