fastmatch

package
v1.16.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2021 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pattern

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

Pattern matches a string and extracts key/value pairs.

func Compile

func Compile(pattern string) (*Pattern, error)

Compile compiles a pattern. Patterns use `%{` and `}` delimiters to define the placing of fields in a string. Two consecutive fields *must* have some delimiter text between them for the pattern to be valid. For example: `%{foo} %{bar}` is valid `%{foo}%{bar}` is not valid Pattern names currently have no restrictions apart from that they cannot contain `}`. Please be conservative with your field names as that might change in the future...

func (*Pattern) FieldName

func (p *Pattern) FieldName(i int) string

Returns a non-empty field name by index. Panics if index is out of range. Use in conjunction with NumFields to check the range

func (*Pattern) MatchString

func (p *Pattern) MatchString(dst []string, src string) ([]string, error)

MatchString matches src and appends key/value pairs to dst. Note that if an error occurs the original slice is returned.

func (*Pattern) NumFields

func (p *Pattern) NumFields() int

Returns the number of non-empty field names

Jump to

Keyboard shortcuts

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