import "golang.org/x/text/search"
Package search provides language-specific search and string matching.
Natural language matching can be intricate. For example, Danish will insist "Århus" and "Aarhus" are the same name and Turkish will match I to ı (note the lack of a dot) in a case-insensitive match. This package handles such language-specific details.
Text passed to any of the calls in this message does not need to be normalized.
index.go pattern.go search.go tables.go
const CLDRVersion = "23"
CLDRVersion is the CLDR version from which the tables in this package are derived.
const UnicodeVersion = "6.2.0"
UnicodeVersion is the Unicode version from which the tables in this package are derived.
var ( // Supported lists the languages for which search differs from its parent. Supported language.Coverage )
An IndexOption specifies how the Index methods of Pattern or Matcher should match the input.
const ( // Anchor restricts the search to the start (or end for Backwards) of the // text. Anchor IndexOption = 1 << iota // Backwards starts the search from the end of the text. Backwards )
type Matcher struct {
// contains filtered or unexported fields
}
A Matcher implements language-specific string matching.
New returns a new Matcher for the given language and options.
Compile compiles and returns a pattern that can be used for faster searching.
CompileString compiles and returns a pattern that can be used for faster searching.
Equal reports whether a and b are equivalent.
EqualString reports whether a and b are equivalent.
func (m *Matcher) Index(b, pat []byte, opts ...IndexOption) (start, end int)
Index reports the start and end position of the first occurrence of pat in b or -1, -1 if pat is not present.
func (m *Matcher) IndexString(s, pat string, opts ...IndexOption) (start, end int)
IndexString reports the start and end position of the first occurrence of pat in s or -1, -1 if pat is not present.
An Option configures a Matcher.
var ( // WholeWord restricts matches to complete words. The default is to match at // the character level. WholeWord Option = nil // Exact requires that two strings are their exact equivalent. For example // å would not match aa in Danish. It overrides any of the ignore options. Exact Option = nil // Loose causes case, diacritics and width to be ignored. Loose Option = loose // IgnoreCase enables case-insensitive search. IgnoreCase Option = ignoreCase // IgnoreDiacritics causes diacritics to be ignored ("ö" == "o"). IgnoreDiacritics Option = ignoreDiacritics // IgnoreWidth equates narrow with wide variants. IgnoreWidth Option = ignoreWidth )
type Pattern struct {
// contains filtered or unexported fields
}
A Pattern is a compiled search string. It is safe for concurrent use.
func (p *Pattern) Index(b []byte, opts ...IndexOption) (start, end int)
Index reports the start and end position of the first occurrence of p in b or -1, -1 if p is not present.
func (p *Pattern) IndexString(s string, opts ...IndexOption) (start, end int)
IndexString reports the start and end position of the first occurrence of p in s or -1, -1 if p is not present.
Package search imports 4 packages (graph). Updated about 15 hours ago. Refresh now. Tools for package owners.