Socket
Socket
Sign inDemoInstall

github.com/VerbalExpressions/GoVerbalExpressions

Package Overview
Dependencies
0
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    github.com/VerbalExpressions/GoVerbalExpressions

This is a Go implementation of VerbalExpressions for other languages. Check http://VerbalExpressions.github.io to know the other implementations. VerbalExperssions is a way to build complex regular expressions with a verbal language. The repo name is "GoVerbalExpressions" but the real package name is "verbalexpressions". So, to import verbalexpressions package, just do: Then, use "verbalexpressions" as prefix. There is a simple example Use "New()" factory then you can chain calls. Go syntax allows you to set new line after seperators: Then, you can use "Test()" method to check if your string matches expression. You may get the regexp.Regexp structure using "Regex()" method, then use common methods to split, replace, find submatches and so on... as usual There are some helpers that use direct call to the regexp package: - Replace - Captures - Test Copyright 2013 Patrice FERLET Use of this source code is governed by MIT-style license that can be found in the LICENSE file


Version published

Readme

Source

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

FAQs

Last updated on 10 Apr 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc