fork download
  1. object Main extends App {
  2. val text = "red 1 green 3 blue"
  3. println( text.split("red|green|blue").mkString(";") )
  4. println( text.split("red|green|blue", -1).mkString(";") )
  5. println( text.split("red|green|blue").filter(_.nonEmpty).mkString(";") )
  6. }
Success #stdin #stdout 0.53s 68344KB
stdin
Standard input is empty
stdout
; 1 ; 3 
; 1 ; 3 ;
 1 ; 3