Coder Social home page Coder Social logo

goverbalexpressions's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.