pattern

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidPct = errors.New("invalid use of '%'")

Functions

func ErrInvalidCaptureIdx

func ErrInvalidCaptureIdx(i int) error

Types

type Capture

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

A Capture represents a matching substring.

func (Capture) End

func (c Capture) End() int

End index of the capture.

func (Capture) IsEmpty

func (c Capture) IsEmpty() bool

IsEmpty is trye if the Capture is empty.

func (Capture) Start

func (c Capture) Start() int

Start index of the capture.

type Pattern

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

A Pattern is a data structure able to interpret a Lua "pattern" (see e.g. https://www.lua.org/manual/5.3/manual.html#6.4.1).

func New

func New(ptn string) (*Pattern, error)

New returns a new Pattern built from the given string (or an error if it is not a valid pattern string).

func (*Pattern) Match

func (p *Pattern) Match(s string, init int, budget uint64) (captures []Capture, used uint64)

Match returns a slice of Capture instances that match the given string, starting from the `init` index.

func (*Pattern) MatchFromStart

func (p *Pattern) MatchFromStart(s string, init int, budget uint64) (captures []Capture, used uint64)

MatchFromStart returns a slice of Capture instances that match the given string, starting from the `init` index.

Jump to

Keyboard shortcuts

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