fork download
  1. class Ideone {
  2. static void main(String[] args) {
  3. String text = "red 1 green 3 blue"
  4. println(text.split(/red|green|blue/))
  5. println(text.split(/red|green|blue/, -1))
  6. println(text.split(/red|green|blue/).findAll {it != ""})
  7. }
  8. }
  9.  
Success #stdin #stdout 1.79s 132452KB
stdin
Standard input is empty
stdout
[,  1 ,  3 ]
[,  1 ,  3 , ]
[ 1 ,  3 ]