"1234".matches("""\d{4}""") //> res0: Boolean = true new scala.util.matching.Regex("""\d{4}""").findFirstIn("1234").nonEmpty //> res1: Boolean = true """\d{4}""".r.findFirstIn("1234").nonEmpty //> res2: Boolean = true val dateP1 = """(\d\d\d\d)-(\d\d)-(\d\d)""".r //> dateP1 : scala.util.matching.Regex = (\d\d\d\d)-(\d\d)-(\d\d) "2011-07-15" match { case dateP1(year, month, day) => true case _ => f