Scala Regex is so Easy!

In scala you can use .r operator to create a regex from string. It becomes trivial:

val speech = """Four score and
               |seven years ago""".stripMargin

val pattern = "\\w+".r

pattern.findFirstIn(speech);

prints Some(Four).

image-20220525151735208


To contact me, send an email anytime or leave a comment below.