Which pattern would you choose?

Report a typo

What will be the output of the following Scala code?

val pattern1 = "...?".r
val pattern2 = "([a-zA-Z]+).?".r
val pattern3 = "([A-Z]+)([a-z]+)([0-9]).?".r

"ABCabc12" match {
  case pattern1() => println("Input is pattern1")
  case pattern2(text) => println(s"Text: $text")
  case pattern3(capital, usual, digits) => println(s"Capital: $capital, Usual: $usual, Digits: $digits")
  case _ => println("No matched")
}
Select one option from the list
___

Create a free account to access the full topic