regex

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2021 License: Apache-2.0 Imports: 4 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")
)
View Source
var (
	// CompileHistogram describes a regexp compile time.
	CompileHistogram = discard.NewHistogram()

	// MatchHistogram describes a regexp match time.
	MatchHistogram = discard.NewHistogram()
)

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 New

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

New creates a new Matcher with the specified regex engine.

func NewGo

func NewGo(re string) (Matcher, Disposer, error)

NewGo creates a new Matcher using go regex engine.

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, Disposer, error)

Constructor creates a new Matcher.

type DisposableMatcher added in v0.11.0

type DisposableMatcher interface {
	Matcher
	Disposer
}

DisposableMatcher implements both Disposer and Matcher

func NewDisposableMatcher added in v0.11.0

func NewDisposableMatcher(name, re string) (DisposableMatcher, error)

type Disposer

type Disposer interface {
	Dispose()
}

Disposer interface is used to release resources. The interface should be implemented by all go binding for native C libraries

type Go

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

Go holds go regex engine Matcher.

func (*Go) Dispose

func (*Go) Dispose()

Dispose implements Disposer interface.

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.

Jump to

Keyboard shortcuts

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