Documentation ¶
Overview ¶
Package ac provides an implementation of the Aho-Corasick string matching algorithm. Throughout this code []byte is referred to as a blice.
http://en.wikipedia.org/wiki/Aho%E2%80%93Corasick_string_matching_algorithm
Copyright (c) 2013 CloudFlare, Inc.
Originally from https://github.com/cloudflare/ahocorasick
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Matcher ¶
type Matcher struct {
// contains filtered or unexported fields
}
Matcher contains a list of blices to match against
func CompileString ¶
CompileString creates a new Matcher used to match against a set of strings (this is a helper to make initialization easy)
func MustCompile ¶
MustCompile returns a Matcher or panics
func MustCompileString ¶
MustCompileString returns a Matcher or panics
func (*Matcher) FindAll ¶
FindAll searches in for blices and returns all the blices found in the original dictionary
func (*Matcher) FindAllString ¶
FindAllString searches in for blices and returns all the blices (as strings) found as in the original dictionary
Example ¶
m := MustCompileString([]string{"Superman", "uperman", "perman", "erman"}) matches := m.FindAllString("The Man Of Steel: Superman") fmt.Println(matches)
Output: [Superman uperman perman erman]
func (*Matcher) MatchString ¶
MatchString returns true if the input slice contains any subslices
Example ¶
m := MustCompileString([]string{"Superman", "uperman", "perman", "erman"}) contains := m.MatchString("The Man Of Steel: Superman") fmt.Println(contains)
Output: true