import scala.util.matching._ val pattern = """(\w+) = (\w+);""".r //pattern必须全部cover住被匹配的字符串 //1. val pattern(a, b) = "shit = game;"// val a = shit; val b = game //2. no exception "shit = game"match { case pattern(a, b) => ... case _ => println("no matches") }