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

后端 未结 6 412
长发绾君心
长发绾君心 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:37

    I don't know Scala all that well, but it looks like you can just do:

    "5".matches("\\d")
    

    References

    • http://langref.org/scala/pattern-matching/matching

提交回复
热议问题