Scala Regex enable Multiline option

后端 未结 3 1134
滥情空心
滥情空心 2020-12-08 11:05

I\'m learning Scala, so this is probably pretty noob-irific.

I want to have a multiline regular expression.

In Ruby it would be:

MY_REGEX = /         


        
3条回答
  •  失恋的感觉
    2020-12-08 11:40

    Just a small addition, use tried to use the (?m) (Multiline) flag (although it might not be suitable here) but here is the right way to use it:

    e.g. instead of

    val ScriptNode =  new Regex("""?m""")
    

    use

    val ScriptNode =  new Regex("""(?m)""")
    

    But again the (?s) flag is more suitable in this question (adding this answer only because the title is "Scala Regex enable Multiline option")

提交回复
热议问题