match

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2024 License: MIT Imports: 0 Imported by: 1

Documentation

Overview

Package match provides a structure for Aho-Corasick output.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Match

type Match struct {
	// Pattern is a string value of a matched pattern.
	Pattern string
	// PatternIndex is a position of a pattern in the patterns slice
	// used for initialization of the trie.
	PatternIndex int
	// Pos is an optional field that provides start and end positions of the
	// pattern on the sarched string.
	*Pos
}

Match contains data of one pattern matched to a string.

func New

func New(pattern string, index, end int) Match

New creates a new instance of a Match entity. It takes the pattern string, its index in the slice used for the trie creation, and the end position of the detected pattern occurence.

func Uniq

func Uniq(matches []Match) []Match

Uniq takes a list of matched patterns occurences and returns back unique list of them.

type Pos

type Pos struct {
	// Start is the byte offset of the start of a pattern on the searched string.
	Start int
	// End is the byte offset of the end of a pattern on the searched string.
	// If End is used for providing a slice, it has to be incremented by one:
	// `haystack[pos.Start:pos.End+1]`
	End int
}

Pos contains positional data of a pattern on the search string.

Jump to

Keyboard shortcuts

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