Skip to content

Latest commit

 

History

History
37 lines (32 loc) · 1.21 KB

README.md

File metadata and controls

37 lines (32 loc) · 1.21 KB

Regular Map

This project aims to make mapping RegEx matches to objects or function calls a trivial task.

Example (see the wiki for more information)

The following example will illustrate how a match gets mapped to an object.

// A simple data class
data class Person(@NamedGroup("firstname") val firstname: String, @NamedGroup("lastname") val lastname: String)

// The logic
val pattern = Pattern.compile("(?<firstname>[a-z]+)[ ](?<lastname>[a-z]+)", Pattern.CASE_INSENSITIVE)
val person = pattern.mapObject<Person>("Philipp Ploder")

// The variable <person> now contains the object Person("Philipp", "Ploder")

Installation

Either download the latest release from the Releases tab or use Maven with a custom repository.

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>
<dependency>
    <groupId>com.github.Fylipp</groupId>
    <artifactId>regular-map</artifactId>
    <version>v1.0.0</version>
</dependency>

License

See the LICENSE file in the root directory of the repository.