scala-regex-interpolation

String interpolation of regex capture groups in scala match statements

License

License

MIT
Categories

Categories

Scala Languages
GroupId

GroupId

dev.bgahagan
ArtifactId

ArtifactId

scala-regex-interpolation_2.12
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

scala-regex-interpolation
String interpolation of regex capture groups in scala match statements
Project URL

Project URL

https://github.com/bgahagan/scala-regex-interpolation
Project Organization

Project Organization

dev.bgahagan
Source Code Management

Source Code Management

https://github.com/bgahagan/scala-regex-interpolation

Download scala-regex-interpolation_2.12

How to add to project

<!-- https://jarcasting.com/artifacts/dev.bgahagan/scala-regex-interpolation_2.12/ -->
<dependency>
    <groupId>dev.bgahagan</groupId>
    <artifactId>scala-regex-interpolation_2.12</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/dev.bgahagan/scala-regex-interpolation_2.12/
implementation 'dev.bgahagan:scala-regex-interpolation_2.12:1.0.0'
// https://jarcasting.com/artifacts/dev.bgahagan/scala-regex-interpolation_2.12/
implementation ("dev.bgahagan:scala-regex-interpolation_2.12:1.0.0")
'dev.bgahagan:scala-regex-interpolation_2.12:jar:1.0.0'
<dependency org="dev.bgahagan" name="scala-regex-interpolation_2.12" rev="1.0.0">
  <artifact name="scala-regex-interpolation_2.12" type="jar" />
</dependency>
@Grapes(
@Grab(group='dev.bgahagan', module='scala-regex-interpolation_2.12', version='1.0.0')
)
libraryDependencies += "dev.bgahagan" % "scala-regex-interpolation_2.12" % "1.0.0"
[dev.bgahagan/scala-regex-interpolation_2.12 "1.0.0"]

Dependencies

compile (1)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.12.8

test (1)

Group / Artifact Type Version
org.scalatest : scalatest_2.12 jar 3.0.8

Project Modules

There are no modules declared in this project.

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.

Versions

Version
1.0.0