KotlinVerbalExpressions

Kotlin regular expressions made easy.

  • Owner: VerbalExpressions/KotlinVerbalExpressions
  • Platform:
  • License:: MIT License
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

KotlinVerbalExpressions Build Status

This is a Kotlin implementation of VerbalExpressions, mostly based on the Java, Swift, and Scala implementations.

Examples

Simple URL test:

val verex = VerEx()
        .startOfLine()
        .then("http")
        .maybe("s")
        .then("://")
        .maybe("www")
        .anythingBut(" ")
        .endOfLine()

val url = "https://www.google.com"

// regular test with VerEx method
if(verex.test(url)) {
    println("Correct url")
}

// test with infix extension
if(url matches verex) {
    println("Correct url")
}

Replacing strings:

val str = "I like birds and bridges"

val verex = VerEx()
        .then("b")
        .anythingBut(" ").zeroOrMore()

val result = verex.replace(str, "trains")

println(result) // I like trains and trains

For more usage examples, see the included tests.

Installation

Maven
<dependency>
  <groupId>co.zsmb</groupId>
  <artifactId>kotlinverbalexpressions</artifactId>
  <version>0.1</version>
</dependency>
Gradle
repositories {
    jcenter()
    // or, alternatively:
    maven { url 'https://dl.bintray.com/zsmb13/KotlinVerbalExpressions/' }
}

dependencies {
    compile 'co.zsmb:kotlinverbalexpressions:0.1'
}

Main metrics

Overview
Name With OwnerVerbalExpressions/KotlinVerbalExpressions
Primary LanguageKotlin
Program languageKotlin (Language Count: 1)
Platform
License:MIT License
所有者活动
Created At2017-05-30 17:43:13
Pushed At2023-06-21 21:18:32
Last Commit At2018-09-05 17:51:25
Release Count0
用户参与
Stargazers Count159
Watchers Count26
Fork Count12
Commits Count33
Has Issues Enabled
Issues Count0
Issue Open Count0
Pull Requests Count1
Pull Requests Open Count0
Pull Requests Close Count1
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private