Documentation ¶
Overview ¶
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 ¶
- Constants
- Variables
- type IndexOption
- type Matcher
- func (m *Matcher) Compile(b []byte) *Pattern
- func (m *Matcher) CompileString(s string) *Pattern
- func (m *Matcher) Equal(a, b []byte) bool
- func (m *Matcher) EqualString(a, b string) bool
- func (m *Matcher) Index(b, pat []byte, opts ...IndexOption) (start, end int)
- func (m *Matcher) IndexString(s, pat string, opts ...IndexOption) (start, end int)
- type Option
- type Pattern
Constants ¶
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.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type IndexOption ¶
type IndexOption byte
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 ¶
type Matcher struct {
// contains filtered or unexported fields
}
A Matcher implements language-specific string matching.
func New ¶
New returns a new Matcher for the given language and options.
func (*Matcher) Compile ¶
Compile compiles and returns a pattern that can be used for faster searching.
func (*Matcher) CompileString ¶
CompileString compiles and returns a pattern that can be used for faster searching.
func (*Matcher) Equal ¶
Equal reports whether a and b are equivalent.
func (*Matcher) EqualString ¶
EqualString reports whether a and b are equivalent.
func (*Matcher) Index ¶
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 (*Matcher) IndexString ¶
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.
type Option ¶
type Option func(*Matcher)
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 ¶
type Pattern struct {
// contains filtered or unexported fields
}
A Pattern is a compiled search string. It is safe for concurrent use.
func (*Pattern) Index ¶
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 (*Pattern) IndexString ¶
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.