Skip to content

About

An enhanced glob interpolator for Scala with format strings

Resources

Stars

14 stars

Watchers

3 watching

Forks

Latest commit

 

History

25 Commits

Folders and files

Repository files navigation

enhanced-string-interpolator

CI status javadoc

An enhanced glob interpolator for Scala with format strings

read full usage in the documentation, or the original inspiration in my blog post

Note that JDK 17+ is required

Basic usage

import stringmatching.regex.Interpolators.r

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

Below is a table of all the useful format strings:

Format Binding Note
$foo foo: String
$foo%d foo: Int
$foo%L foo: Long
$foo%f foo: Float
$foo%g foo: Double
$foo...(<regex>) foo: Seq[String] split by regex
$foo..!(<regex>) foo: Seq[String] drops first if empty
${r"$foo%d"}...(<regex>) foo: Seq[Int] match on each element
${r"$foo%L"}...(<regex>) foo: Seq[Long] match on each element
${r"$foo%f"}...(<regex>) foo: Seq[Float] match on each element
${r"$foo%g"}...(<regex>) foo: Seq[Double] match on each element

About

An enhanced glob interpolator for Scala with format strings

Resources

Stars

14 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages