Skip to content

String interpolation of regex capture groups in scala match statements

License

Notifications You must be signed in to change notification settings

bgahagan/scala-regex-interpolation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Regex String Interpolation Utility

Maven Central

A small library that allows interpolation of regex capture groups in match statements.

The nth interpolant (e.g. $group1) will match against the nth capture group in the regex.

Example

import dev.bgahagan.regex.intrpl._

"hello world" match {
  case r"(\w+)$group1 (\w+)$group2" => 
    println(group2)
}

Outputs:

world

Design Notes

  • The regex is parsed and compiled on each match invocation.

About

String interpolation of regex capture groups in scala match statements

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages