regex

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2019 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrRegexAlreadyRegistered is returned when there is a previously
	// registered regex engine with the same name.
	ErrRegexAlreadyRegistered = errors.NewKind("Regex engine already registered: %s")
	// ErrRegexNameEmpty returned when the name is "".
	ErrRegexNameEmpty = errors.NewKind("Regex engine name cannot be empty")
	// ErrRegexNotFound returned when the regex engine is not registered.
	ErrRegexNotFound = errors.NewKind("Regex engine not found: %s")
)

Functions

func Default

func Default() string

Default returns the default regex engine.

func Engines

func Engines() []string

Engines returns the list of regex engines names.

func Register

func Register(name string, c Constructor) error

Register add a new regex engine to the registry.

func SetDefault

func SetDefault(name string)

SetDefault sets the regex engine returned by Default.

Types

type Constructor

type Constructor func(re string) (Matcher, error)

Constructor creates a new Matcher.

type Go

type Go struct {
	// contains filtered or unexported fields
}

Go holds go regex engine Matcher.

func (*Go) Match

func (r *Go) Match(s string) bool

Match implements Matcher interface.

type Matcher

type Matcher interface {
	// Match returns true if the text matches the regular expression.
	Match(text string) bool
}

Matcher interface is used to compare regexes with strings.

func New

func New(name, re string) (Matcher, error)

New creates a new Matcher with the specified regex engine.

func NewGo

func NewGo(re string) (Matcher, error)

NewGo creates a new Matcher using go regex engine.

Jump to

Keyboard shortcuts

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