KotlinVerbalExpressions

Kotlin regular expressions made easy.

  • 所有者: VerbalExpressions/KotlinVerbalExpressions
  • 平台:
  • 许可证: MIT License
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

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'
}

主要指标

概览
名称与所有者VerbalExpressions/KotlinVerbalExpressions
主编程语言Kotlin
编程语言Kotlin (语言数: 1)
平台
许可证MIT License
所有者活动
创建于2017-05-30 17:43:13
推送于2023-06-21 21:18:32
最后一次提交2018-09-05 17:51:25
发布数0
用户参与
星数159
关注者数26
派生数12
提交数33
已启用问题?
问题数0
打开的问题数0
拉请求数1
打开的拉请求数0
关闭的拉请求数1
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?