compiler

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 13, 2017 License: Apache-2.0 Imports: 3 Imported by: 6 modules, 10 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

compiler

Read the docs.

Documentation

Overview

Package compiler offers a regexp compiler which compiles regex templates to regexp.Regexp

reg, err := compiler.CompileRegex("foo:bar.baz:<[0-9]{2,10}>", '<', '>')
// if err != nil ...
reg.MatchString("foo:bar.baz:123")

reg, err := compiler.CompileRegex("/foo/bar/url/{[a-z]+}", '{', '}')
// if err != nil ...
reg.MatchString("/foo/bar/url/abz")

This package is adapts github.com/gorilla/mux/regexp.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompileRegex

func CompileRegex(tpl string, delimiterStart, delimiterEnd byte) (*regexp.Regexp, error)

CompileRegex parses a template and returns a Regexp.

You can define your own delimiters. It is e.g. common to use curly braces {} but I recommend using characters which have no special meaning in Regex, e.g.: <, >

reg, err := compiler.CompileRegex("foo:bar.baz:<[0-9]{2,10}>", '<', '>')
// if err != nil ...
reg.MatchString("foo:bar.baz:123")

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL