expr

package
v1.0.43 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2024 License: MIT Imports: 3 Imported by: 1

Documentation

Overview

Package expr implements text matching.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Expr

type Expr interface {
	Match(data []byte) (mRes *MatchRes, ok bool)
	Repr() string
}

type ExprList

type ExprList interface {
	Expr
	Add(name string, expr Expr)
	GetName(no int) string
	Delete(name string)
}

func NewSimpleExprList

func NewSimpleExprList(exprs ...Expr) ExprList

func NewSimpleExprListNamed

func NewSimpleExprListNamed(exprs map[string][]Expr) ExprList

func NewSimpleExprListNamedOrdered

func NewSimpleExprListNamedOrdered(exprs []NamedExpr) ExprList

type MatchRes

type MatchRes struct {
	Start      int
	End        int
	GroupDict  map[string][]byte
	PatternNo  int
	Underlying *MatchRes // for result chaining
}

type NamedExpr

type NamedExpr struct {
	Name  string
	Exprs []Expr
}

type SimpleExprBuilder added in v1.0.26

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

func NewSimpleExpr

func NewSimpleExpr() *SimpleExprBuilder

NewSimpleExpr returns builder that creates a simple expr that will process data as is

func NewSimpleExprFirst

func NewSimpleExprFirst(first int) *SimpleExprBuilder

NewSimpleExprLast returns builder that creates a simple expr that will match only first n bytes of data

func NewSimpleExprFirst200

func NewSimpleExprFirst200() *SimpleExprBuilder

NewSimpleExprFirst200 is a wrapper around NewSimpleExprFirst with first fixed to 200

func NewSimpleExprLast

func NewSimpleExprLast(last int) *SimpleExprBuilder

NewSimpleExprLast returns builder that creates a simple expr that will match only last n bytes of data

func NewSimpleExprLast20

func NewSimpleExprLast20() *SimpleExprBuilder

NewSimpleExprLast20 is a wrapper around NewSimpleExprLast with last fixed to 20

func NewSimpleExprLast200

func NewSimpleExprLast200() *SimpleExprBuilder

NewSimpleExprLast200 is a wrapper around NewSimpleExprLast with last fixed to 200

func (*SimpleExprBuilder) FromPattern added in v1.0.26

func (s *SimpleExprBuilder) FromPattern(pattern string) Expr

FromPattern creates a simple expr matcher from compiling given pattern. Panics in case of compilation failure, use your own regex with FromRegex if passed pattern can be incorrect.

func (*SimpleExprBuilder) FromPatternAndExclude added in v1.0.26

func (s *SimpleExprBuilder) FromPatternAndExclude(pattern string, exclude string) Expr

FromPatternAndExclude creates a simple expr matcher from compiling given match and exclude patterns. It will only match data that is matched by regex and is not matched by exclude regex. Panics in case of compilation failure, use your own regex with FromRegexAndExclude if passed patterns can be incorrect.

func (*SimpleExprBuilder) FromRegex added in v1.0.26

func (s *SimpleExprBuilder) FromRegex(regex *regexp.Regexp) Expr

FromRegex creates a simple expr matcher from given regex

func (*SimpleExprBuilder) FromRegexAndExclude added in v1.0.26

func (s *SimpleExprBuilder) FromRegexAndExclude(regex *regexp.Regexp, excludeRegex *regexp.Regexp) Expr

FromRegexAndExclude creates a simple expr matcher from passed regex and exclude. It will only match data that is matched by regex and is not matched by exclude regex.

type SimpleExprList

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

func (*SimpleExprList) Add

func (m *SimpleExprList) Add(name string, expr Expr)

func (*SimpleExprList) Delete

func (m *SimpleExprList) Delete(name string)

func (*SimpleExprList) GetName

func (m *SimpleExprList) GetName(index int) string

func (SimpleExprList) Match

func (m SimpleExprList) Match(data []byte) (*MatchRes, bool)

func (SimpleExprList) Repr

func (m SimpleExprList) Repr() string

func (SimpleExprList) String

func (m SimpleExprList) String() string

Jump to

Keyboard shortcuts

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