val emailRegex: Regex = "(.+)@(.+)\\.(.+)".r
"
[email protected]" match {
case emailRegex(userName, domain, topDomain) => println(s"Hi $userName from $domain")
case _ => println(s"This is not a valid email.")
}
In this example, the regex attem...