fork download
  1. object Main extends App {
  2. val r = "([aeiou]*)?([^aeiou]*)?".r;
  3. Console.println(test("aaabbb"));
  4. Console.println(test("bbbaaa"));
  5.  
  6. def test(s: String) = s match {
  7. case r(vs, cs) => s"$s => vowels=$vs, other=$cs"
  8. case _ => s"$s => no match"
  9. }
  10. }
  11.  
Success #stdin #stdout 0.44s 322496KB
stdin
Standard input is empty
stdout
aaabbb => vowels=aaa, other=bbb
bbbaaa => no match