Matching against a regular expression in Scala

前端 未结 4 953
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-01 02:52

I fairly frequently match strings against regular expressions. In Java:

java.util.regex.Pattern.compile(\"\\w+\").matcher(\"this_is\").matches

Ouch. Scala has

4条回答
  •  遥遥无期
    2021-02-01 03:42

    Currently (Aug 2014, Scala 2.11) @David's reply tells the norm.

    However, it seems the r."..." string interpolator may be on its way to help with this. See How to pattern match using regular expression in Scala?

提交回复
热议问题