scala-textmatching

Unifying simple globs, regex & literal matchers

License

License

Categories

Categories

Scala Languages
GroupId

GroupId

com.madgag
ArtifactId

ArtifactId

scala-textmatching_2.10
Last Version

Last Version

2.1
Release Date

Release Date

Type

Type

jar
Description

Description

scala-textmatching
Unifying simple globs, regex & literal matchers
Project URL

Project URL

https://github.com/rtyley/scala-textmatching
Project Organization

Project Organization

com.madgag
Source Code Management

Source Code Management

https://github.com/rtyley/scala-textmatching

Download scala-textmatching_2.10

How to add to project

<!-- https://jarcasting.com/artifacts/com.madgag/scala-textmatching_2.10/ -->
<dependency>
    <groupId>com.madgag</groupId>
    <artifactId>scala-textmatching_2.10</artifactId>
    <version>2.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.madgag/scala-textmatching_2.10/
implementation 'com.madgag:scala-textmatching_2.10:2.1'
// https://jarcasting.com/artifacts/com.madgag/scala-textmatching_2.10/
implementation ("com.madgag:scala-textmatching_2.10:2.1")
'com.madgag:scala-textmatching_2.10:jar:2.1'
<dependency org="com.madgag" name="scala-textmatching_2.10" rev="2.1">
  <artifact name="scala-textmatching_2.10" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.madgag', module='scala-textmatching_2.10', version='2.1')
)
libraryDependencies += "com.madgag" % "scala-textmatching_2.10" % "2.1"
[com.madgag/scala-textmatching_2.10 "2.1"]

Dependencies

compile (2)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.10.4
com.madgag : globs-for-java jar 0.2

test (1)

Group / Artifact Type Version
org.specs2 : specs2_2.10 jar 2.3.11

Project Modules

There are no modules declared in this project.

scala-textmatching

A small Scala veneer over text-matching that unifies globs, regexs and literals.

scala> import com.madgag.textmatching._
import com.madgag.textmatching._

scala> val textMatchers = Seq(
     | "glob:b?t",
     | "glob:b*t",
     | "glob:*.log",
     | "regex:b+",
     | "literal:b*t",
     | "glob:id_{dsa,rsa}"
     | ).map(TextMatcher(_))
textMatchers: Seq[com.madgag.textmatching.TextMatcher] = List(glob:<b?t>, glob:<b*t>, glob:<*.log>, regex:<b+>, literal:<b*t>, glob:<id_{dsa,rsa}>)

scala> val bitsOfText = Seq("bit", "bat", "bot", "boot", "b*t", "id_dsa", "id_rsa", "app.log")
bitsOfText: Seq[String] = List(bit, bat, bot, boot, b*t, id_dsa, id_rsa, app.log)

scala> bitsOfText.map(s => s -> textMatchers.filter(_.r.matches(s)).mkString(" ")).toMap
res7: scala.collection.immutable.Map[String,String] = Map(
  app.log -> glob:<*.log>,
  bat -> glob:<b?t> glob:<b*t>,
  bit -> glob:<b?t> glob:<b*t>,
  id_dsa -> glob:<id_{dsa,rsa}>,
  boot -> glob:<b*t>,
  id_rsa -> glob:<id_{dsa,rsa}>,
  bot -> glob:<b?t> glob:<b*t>,
  b*t -> glob:<b?t> glob:<b*t> literal:<b*t>
)

Versions

Version
2.1
2.0