Can be made nicer by using the fact, that regexps in Scala are extractors and you can use them to pattern match like at http://ikaisays.com/2009/04/04/using-pattern-matching-with-regular-expressions-in-scala/