regexp

package
v2.9.0-beta1-sd+incomp... Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2020 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package regexp implmenets API of Go's native "regexp" but with caching results in memory

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Match

func Match(pattern string, b []byte) (matched bool, err error)

Match is the same as regexp.Match but returns cached result instead.

func MatchString

func MatchString(pattern string, s string) (matched bool, err error)

MatchString is the same as regexp.MatchString but returns cached result instead.

func QuoteMeta

func QuoteMeta(s string) string

QuoteMeta is the same as regexp.QuoteMeta but returns cached result instead.

func ResetCache

func ResetCache(ttl time.Duration, isEnabled bool)

ResetCache resets cache to initial state

Types

type Regexp

type Regexp struct {
	*regexp.Regexp
	FromCache bool
}

Regexp is a wrapper around regexp.Regexp but with caching

func Compile

func Compile(expr string) (*Regexp, error)

Compile does the same as regexp.Compile but returns cached *Regexp instead.

func CompilePOSIX

func CompilePOSIX(expr string) (*Regexp, error)

CompilePOSIX does the same as regexp.CompilePOSIX but returns cached *Regexp instead.

func MustCompile

func MustCompile(str string) *Regexp

MustCompile is the same as regexp.MustCompile but returns cached *Regexp instead.

func MustCompilePOSIX

func MustCompilePOSIX(str string) *Regexp

MustCompilePOSIX is the same as regexp.MustCompilePOSIX but returns cached *Regexp instead.

func (*Regexp) Copy

func (re *Regexp) Copy() *Regexp

Copy returns a new Regexp object copied from re.

When using a Regexp in multiple goroutines, giving each goroutine its own copy helps to avoid lock contention.

func (*Regexp) Expand

func (re *Regexp) Expand(dst []byte, template []byte, src []byte, match []int) []byte

Expand is the same as regexp.Regexp.Expand but returns cached result instead.

func (*Regexp) ExpandString

func (re *Regexp) ExpandString(dst []byte, template string, src string, match []int) []byte

ExpandString is the same as regexp.Regexp.ExpandString but returns cached result instead.

func (*Regexp) Find

func (re *Regexp) Find(b []byte) []byte

Find is the same as regexp.Regexp.Find but returns cached result instead.

func (*Regexp) FindAll

func (re *Regexp) FindAll(b []byte, n int) [][]byte

FindAll is the same as regexp.Regexp.FindAll but returns cached result instead.

func (*Regexp) FindAllIndex

func (re *Regexp) FindAllIndex(b []byte, n int) [][]int

FindAllIndex is the same as regexp.Regexp.FindAllIndex but returns cached result instead.

func (*Regexp) FindAllString

func (re *Regexp) FindAllString(s string, n int) []string

FindAllString is the same as regexp.Regexp.FindAllString but returns cached result instead.

func (*Regexp) FindAllStringIndex

func (re *Regexp) FindAllStringIndex(s string, n int) [][]int

FindAllStringIndex is the same as regexp.Regexp.FindAllStringIndex but returns cached result instead.

func (*Regexp) FindAllStringSubmatch

func (re *Regexp) FindAllStringSubmatch(s string, n int) [][]string

FindAllStringSubmatch is the same as regexp.Regexp.FindAllStringSubmatch but returns cached result instead.

func (*Regexp) FindAllStringSubmatchIndex

func (re *Regexp) FindAllStringSubmatchIndex(s string, n int) [][]int

FindAllStringSubmatchIndex is the same as regexp.Regexp.FindAllStringSubmatchIndex but returns cached result instead.

func (*Regexp) FindAllSubmatch

func (re *Regexp) FindAllSubmatch(b []byte, n int) [][][]byte

FindAllSubmatch is the same as regexp.Regexp.FindAllSubmatch but returns cached result instead.

func (*Regexp) FindAllSubmatchIndex

func (re *Regexp) FindAllSubmatchIndex(b []byte, n int) [][]int

FindAllSubmatchIndex is the same as regexp.Regexp.FindAllSubmatchIndex but returns cached result instead.

func (*Regexp) FindIndex

func (re *Regexp) FindIndex(b []byte) (loc []int)

FindIndex is the same as regexp.Regexp.FindIndex but returns cached result instead.

func (*Regexp) FindReaderIndex

func (re *Regexp) FindReaderIndex(r io.RuneReader) (loc []int)

FindReaderIndex is the same as regexp.Regexp.FindReaderIndex (NO CACHE).

func (*Regexp) FindReaderSubmatchIndex

func (re *Regexp) FindReaderSubmatchIndex(r io.RuneReader) []int

FindReaderSubmatchIndex is the same as regexp.Regexp.FindReaderSubmatchIndex (NO CACHE).

func (*Regexp) FindString

func (re *Regexp) FindString(s string) string

FindString is the same as regexp.Regexp.FindString but returns cached result instead.

func (*Regexp) FindStringIndex

func (re *Regexp) FindStringIndex(s string) (loc []int)

FindStringIndex is the same as regexp.Regexp.FindStringIndex but returns cached result instead.

func (*Regexp) FindStringSubmatch

func (re *Regexp) FindStringSubmatch(s string) []string

FindStringSubmatch is the same as regexp.Regexp.FindStringSubmatch but returns cached result instead.

func (*Regexp) FindStringSubmatchIndex

func (re *Regexp) FindStringSubmatchIndex(s string) []int

FindStringSubmatchIndex is the same as regexp.Regexp.FindStringSubmatchIndex but returns cached result instead.

func (*Regexp) FindSubmatch

func (re *Regexp) FindSubmatch(b []byte) [][]byte

FindSubmatch is the same as regexp.Regexp.FindSubmatch but returns cached result instead.

func (*Regexp) FindSubmatchIndex

func (re *Regexp) FindSubmatchIndex(b []byte) []int

FindSubmatchIndex is the same as regexp.Regexp.FindSubmatchIndex but returns cached result instead.

func (*Regexp) LiteralPrefix

func (re *Regexp) LiteralPrefix() (prefix string, complete bool)

LiteralPrefix returns a literal string that must begin any match Calls regexp.Regexp.LiteralPrefix

func (*Regexp) Longest

func (re *Regexp) Longest()

Longest calls regexp.Regexp.Longest of wrapped regular expression

func (*Regexp) Match

func (re *Regexp) Match(b []byte) bool

Match reports whether the Regexp matches the byte slice b.

func (*Regexp) MatchReader

func (re *Regexp) MatchReader(r io.RuneReader) bool

MatchReader reports whether the Regexp matches the text read by the RuneReader. Calls regexp.Regexp.MatchReader (NO CACHE)

func (*Regexp) MatchString

func (re *Regexp) MatchString(s string) bool

MatchString reports whether the Regexp matches the string s.

func (*Regexp) NumSubexp

func (re *Regexp) NumSubexp() int

NumSubexp returns result of regexp.Regexp.NumSubexp of wrapped regular expression.

func (*Regexp) ReplaceAll

func (re *Regexp) ReplaceAll(src, repl []byte) []byte

ReplaceAll is the same as regexp.Regexp.ReplaceAll but returns cached result instead.

func (*Regexp) ReplaceAllFunc

func (re *Regexp) ReplaceAllFunc(src []byte, repl func([]byte) []byte) []byte

ReplaceAllFunc is the same as regexp.Regexp.ReplaceAllFunc but returns cached result instead.

func (*Regexp) ReplaceAllLiteral

func (re *Regexp) ReplaceAllLiteral(src, repl []byte) []byte

ReplaceAllLiteral is the same as regexp.Regexp.ReplaceAllLiteral but returns cached result instead.

func (*Regexp) ReplaceAllLiteralString

func (re *Regexp) ReplaceAllLiteralString(src, repl string) string

ReplaceAllLiteralString is the same as regexp.Regexp.ReplaceAllLiteralString but returns cached result instead.

func (*Regexp) ReplaceAllString

func (re *Regexp) ReplaceAllString(src, repl string) string

ReplaceAllString is the same as regexp.Regexp.ReplaceAllString but returns cached result instead.

func (*Regexp) ReplaceAllStringFunc

func (re *Regexp) ReplaceAllStringFunc(src string, repl func(string) string) string

ReplaceAllStringFunc is the same as regexp.Regexp.ReplaceAllStringFunc but returns cached result instead.

func (*Regexp) Split

func (re *Regexp) Split(s string, n int) []string

Split is the same as regexp.Regexp.Split but returns cached result instead.

func (*Regexp) String

func (re *Regexp) String() string

String returns the source text used to compile the wrapped regular expression.

func (*Regexp) SubexpNames

func (re *Regexp) SubexpNames() []string

SubexpNames returns result of regexp.Regexp.SubexpNames of wrapped regular expression.

Jump to

Keyboard shortcuts

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