A new string interpolator for pattern matching

Hello, I have just released 1.0.2 of my enhanced-string-interpolator library!

It supports Scala 3.3 LTS (consider using Scala 3.3.2)

why use it? when s isn’t enough, it adds extra features so you can do stuff like this

(splitting strings with regex)

raw"C:\foo\bar\baz.pdf" match
  case r"C:$elems..!(\\)" => elems.mkString("/","/","")
// yields "/foo/bar/baz.pdf"

(extracting integer values)

"[23, 56, 71]" match
  case r"[${r"$xs%d"}...(, )]" => xs.sum // 150

(and a lot more formats - Long, Double, Float, Int)

generally good for parsing Advent of Code challenges, or competitive coding

Let me know what you think.

8 Likes