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

Thanks! You can always email me or use contact form for more questions/comments etc.


scala

32 Words

2022-05-25