Split string by two conditions

java, scala, split, string

Solution

in Java you would write

String text = "s: saturday, sunday, solar, selfie";
String[] words = text.split("[:,] ");

This will split by an `:` or `,` followed by a space. If the space is optional you could use `"[:,] ?"`

Problem

I have to split this string from ``` val str="s: saturday, sunday, solar, selfie" ``` into an Array ``` s,saturday,sunday,solar,selfie ``` in scala 2.10

Original source