I am trying to iterate through a bunch of strings with enum-like case objects, each of them with their own regex. Doing it in a similar manner as below yields scala.MatchError: somestring (of class java.lang.String). Any idea how to solve it?
case object X {val regex = "somestring".r}
case object Y {val regex = "de".r}
"somestring" match {
case X.regex(_) => 1
case Y.regex(_) => 2