GoVerbalExpressions

Go VerbalExpressions make regular expression easy

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

Github星跟踪图

GoVerbalExpressions

Build Status
Coverage Status

Go VerbalExpressions implementation

VerbalExpression is a concept to help building difficult regular expressions.

See online doc here: http://godoc.org/github.com/VerbalExpressions/GoVerbalExpressions

Other Implementations

You can see an up to date list of all ports on VerbalExpressions.github.io.

Installation

Use this command line:

go get github.com/VerbalExpressions/GoVerbalExpressions

This will install package in your $GOPATH and you will be ready to import it.

Examples


// import with a nice name
import (
    "github.com/VerbalExpressions/GoVerbalExpressions" // imports verbalexpressions package
    "fmt"
)

func main () {
    v := verbalexpressions.New().
            StartOfLine().
            Then("http").
            Maybe("s").
            Then( "://").
            Maybe("www.").
            AnythingBut(" ").
            EndOfLine()

    testMe := "https://www.google.com"
    
    if v.Test(testMe) {
       fmt.Println("You have a valid URL") 
    } else {
       fmt.Println("URL is incorrect") 
    }
}

We try to give alias method and/or helpers. For example:


    // s will be "We have a blue house"
    s := verbalexpressions.New().Find("red").Replace("We have a red house", "blue")

    // c will be:
    // [
    //    ["http://www.google.com",  "http://", "www.google.com"]
    // ]
    c := verbalexpressions.New().
        BeginCapture().
            Find("http").Maybe("s").Find("://").
        EndCapture().
        BeginCapture().
            Find("www.").Anything().
        EndCapture().
        Captures("http://www.google.com")

    // check c[0][1] => http://
    //       c[0][2] => www.google.com

主要指标

概览
名称与所有者VerbalExpressions/GoVerbalExpressions
主编程语言Go
编程语言Go (语言数: 1)
平台
许可证MIT License
所有者活动
创建于2013-08-05 23:33:41
推送于2020-04-10 16:27:53
最后一次提交2020-04-10 18:27:51
发布数0
用户参与
星数179
关注者数18
派生数10
提交数89
已启用问题?
问题数5
打开的问题数0
拉请求数25
打开的拉请求数0
关闭的拉请求数0
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?