How to check whether a String fully matches a Regex in Scala?

后端 未结 6 419
长发绾君心
长发绾君心 2020-12-23 11:14

Assume I have a Regex pattern I want to match many Strings to.

val Digit = \"\"\"\\d\"\"\".r

I just want to check whether a given String fu

6条回答
  •  我在风中等你
    2020-12-23 11:38

      """\d""".r.unapplySeq("5").isDefined            //> res1: Boolean = true
      """\d""".r.unapplySeq("a").isDefined            //> res2: Boolean = false
    

提交回复
热议问题