Documentation
¶
Overview ¶
Package stringext defines extra string functions.
Index ¶
- Constants
- func DeEncodeBCD(s string) (min, max [4]byte)
- func EncodeContainsPatternCI(pattern *Pattern) string
- func EncodeContainsPatternCS(pattern *Pattern) string
- func EncodeContainsPatternUTF8CI(pattern *Pattern) string
- func EncodeContainsPrefixCI(needle Needle) string
- func EncodeContainsPrefixCS(needle Needle) string
- func EncodeContainsPrefixUTF8CI(needle Needle) string
- func EncodeContainsSubstrCI(needle Needle) string
- func EncodeContainsSubstrCS(needle Needle) string
- func EncodeContainsSubstrUTF8CI(needle Needle) string
- func EncodeContainsSuffixCI(needle Needle) string
- func EncodeContainsSuffixCS(needle Needle) string
- func EncodeContainsSuffixUTF8CI(needle Needle) string
- func EncodeEqualStringCI(needle Needle) string
- func EncodeEqualStringCS(needle Needle) string
- func EncodeEqualStringUTF8CI(needle Needle) string
- func EncodeFuzzyNeedleASCII(needle Needle) string
- func EncodeFuzzyNeedleUnicode(needle Needle) string
- func EqualRuneFold(a, b rune) bool
- func HasCaseSensitiveChar(str Needle) bool
- func HasNtnRune(r rune) bool
- func HasNtnString(str Needle) bool
- func IndexRuneEscape(runes []rune, r, escape rune) int
- func LastIndexRuneEscape(runes []rune, r, escape rune) int
- func LiteralPrefix(regex string, escape rune) string
- func NormalizeRune(r rune) rune
- func NormalizeString(str string) string
- func NormalizeStringASCIIOnly(bytes []byte) []byte
- func NormalizeStringASCIIOnlyString(str string) string
- func ToBCD(min, max *[4]byte) string
- type Data
- type LikeSegment
- type Needle
- func DeEncodeContainsPrefixCI(needle string) Needle
- func DeEncodeContainsPrefixCS(needle string) Needle
- func DeEncodeContainsPrefixUTF8CI(needle string) Needle
- func DeEncodeContainsSubstrCI(needle string) Needle
- func DeEncodeContainsSubstrCS(needle string) Needle
- func DeEncodeContainsSubstrUTF8CI(needle string) Needle
- func DeEncodeContainsSuffixCI(needle string) Needle
- func DeEncodeContainsSuffixCS(needle string) Needle
- func DeEncodeContainsSuffixUTF8CI(needle string) Needle
- func DeEncodeEqualStringCI(needle string) Needle
- func DeEncodeEqualStringCS(needle string) Needle
- func DeEncodeEqualStringUTF8CI(needle string) Needle
- func DeEncodeFuzzyNeedleASCII(needle string) Needle
- func DeEncodeFuzzyNeedleUnicode(needle string) Needle
- type Pattern
- type StrCmpType
Constants ¶
const NoEscape = utf8.RuneError
NoEscape is the default escape for LIKE parameters; it signals no escape
Variables ¶
This section is empty.
Functions ¶
func EncodeContainsPatternCI ¶
EncodeContainsPatternCI encodes the provided string for usage with bcContainsPatternCi
func EncodeContainsPatternCS ¶
EncodeContainsPatternCS encodes the provided string for usage with bcContainsPatternCs
func EncodeContainsPatternUTF8CI ¶
EncodeContainsPatternUTF8CI encodes the provided string for usage with bcContainsPatternUTF8Ci
func EncodeContainsPrefixCI ¶
EncodeContainsPrefixCI encodes the provided string for usage with bcContainsPrefixCi
func EncodeContainsPrefixCS ¶
EncodeContainsPrefixCS encodes the provided string for usage with bcContainsPrefixCs
func EncodeContainsPrefixUTF8CI ¶
EncodeContainsPrefixUTF8CI encodes the provided string for usage with bcContainsPrefixUTF8Ci
func EncodeContainsSubstrCI ¶
EncodeContainsSubstrCI encodes the provided string for usage with bcContainsSubstrCi
func EncodeContainsSubstrCS ¶
EncodeContainsSubstrCS encodes the provided string for usage with bcContainsSubstrCs
func EncodeContainsSubstrUTF8CI ¶
EncodeContainsSubstrUTF8CI encodes the provided string for usage with bcContainsSubstrUTF8Ci
func EncodeContainsSuffixCI ¶
EncodeContainsSuffixCI encodes the provided string for usage with bcContainsSuffixCi
func EncodeContainsSuffixCS ¶
EncodeContainsSuffixCS encodes the provided string for usage with bcContainsSuffixCs
func EncodeContainsSuffixUTF8CI ¶
EncodeContainsSuffixUTF8CI encodes the provided string for usage with bcContainsSuffixUTF8Ci
func EncodeEqualStringCI ¶
EncodeEqualStringCI encodes the provided string for usage with bcStrCmpEqCi
func EncodeEqualStringCS ¶
EncodeEqualStringCS encodes the provided string for usage with bcStrCmpEqCs
func EncodeEqualStringUTF8CI ¶
EncodeEqualStringUTF8CI encodes the provided string for usage with bcStrCmpEqUTF8Ci
func EncodeFuzzyNeedleASCII ¶
EncodeFuzzyNeedleASCII encode a needle (string) for fuzzy ASCII comparisons
func EncodeFuzzyNeedleUnicode ¶
EncodeFuzzyNeedleUnicode encode a needle (string) for fuzzy unicode comparisons
func EqualRuneFold ¶
func HasCaseSensitiveChar ¶
HasCaseSensitiveChar returns true when the provided string contains a case-sensitive char
func HasNtnRune ¶
HasNtnRune return true when the provided rune contains a non-trivial normalization; false otherwise
func HasNtnString ¶
HasNtnString return true when the provided string contains a non-trivial normalization; false otherwise
func IndexRuneEscape ¶
IndexRuneEscape returns the index of the first instance of the Unicode code point r, or -1 if rune is not present in runes; an escaped r is not matched.
func LastIndexRuneEscape ¶
LastIndexRuneEscape returns the index of the last instance of r in runes, or -1 if c is not present in runes; an escaped r is not matched.
func LiteralPrefix ¶
LiteralPrefix returns the unicode substring that can be matched with a faster substring matcher. Similar to regexp.LiteralPrefix() TODO the proper prefix and necessary substring should be deduced from the DFA, which is much harder but will also allow to find the substring "abc" in regex "(abc|abcde)fgh"
func NormalizeRune ¶
NormalizeRune normalizes the provided rune into the smallest and equal rune wrt case-folding. For ascii this normalization is equal to UPPER
func NormalizeString ¶
NormalizeString normalizes the provided string into a string with runes that are smallest and equal wrt case-folding. For ascii this normalization is equal to UPPER
func NormalizeStringASCIIOnly ¶
NormalizeStringASCIIOnly normalizes the provided string into a string with runes that are smallest and equal wrt case-folding, and leaves non-ASCII values unchanged.
func NormalizeStringASCIIOnlyString ¶
NormalizeStringASCIIOnlyString normalizes the provided string into a string with runes that are smallest and equal wrt case-folding, and leaves non-ASCII values unchanged.
Types ¶
type LikeSegment ¶
LikeSegment is a number of character skips followed by a Pattern. The number of skips is defined by a minimum and maximum count. Eg, {SkipMin:1, SkipMax:1, Pattern:"abc"} states that the segment matches when one (and only one) character is skipped and pattern "abc" matches. SkipMax can be -1 which indicates any number of slips. E.g {SKipMin:1, SkipMax:-1, "a"} corresponds to '_%a' in A LIKE expression.
func SimplifyLikeExpr ¶
func SimplifyLikeExpr(expr string, wc, ks, escape rune) []LikeSegment
SimplifyLikeExpr simplifies a LIKE expression into a minimal sequence of LikeSegment
func (LikeSegment) String ¶
func (ls LikeSegment) String() string
type Needle ¶
type Needle string
Needle string type to distinguish from the Data string type
func DeEncodeContainsPrefixCI ¶
DeEncodeContainsPrefixCI de-encodes the provided string for usage with bcContainsPrefixCi
func DeEncodeContainsPrefixCS ¶
DeEncodeContainsPrefixCS de-encodes the provided string for usage with bcContainsPrefixCs
func DeEncodeContainsPrefixUTF8CI ¶
DeEncodeContainsPrefixUTF8CI de-encodes the provided string for usage with bcContainsPrefixUTF8Ci
func DeEncodeContainsSubstrCI ¶
DeEncodeContainsSubstrCI de-encodes the provided string for usage with bcContainsSubstrCi
func DeEncodeContainsSubstrCS ¶
DeEncodeContainsSubstrCS de-encodes the provided string for usage with bcContainsSubstrCs
func DeEncodeContainsSubstrUTF8CI ¶
DeEncodeContainsSubstrUTF8CI de-encodes the provided string for usage with bcContainsSubstrUTF8Ci
func DeEncodeContainsSuffixCI ¶
DeEncodeContainsSuffixCI de-encodes the provided string for usage with bcContainsSuffixCi
func DeEncodeContainsSuffixCS ¶
DeEncodeContainsSuffixCS de-encodes the provided string for usage with bcContainsSuffixCs
func DeEncodeContainsSuffixUTF8CI ¶
DeEncodeContainsSuffixUTF8CI de-encodes the provided string for usage with bcContainsSuffixUTF8Ci
func DeEncodeEqualStringCI ¶
DeEncodeEqualStringCI de-encodes the provided string for usage with bcStrCmpEqCi
func DeEncodeEqualStringCS ¶
DeEncodeEqualStringCS de-encodes the provided string for usage with bcStrCmpEqCs
func DeEncodeEqualStringUTF8CI ¶
DeEncodeEqualStringUTF8CI de-encodes the provided string for usage with bcStrCmpEqUTF8Ci
func DeEncodeFuzzyNeedleASCII ¶
DeEncodeFuzzyNeedleASCII de-encode a needle (string) for fuzzy ASCII comparisons
func DeEncodeFuzzyNeedleUnicode ¶
DeEncodeFuzzyNeedleUnicode de-encode a needle (string) for fuzzy unicode comparisons
type Pattern ¶
type Pattern struct { WC rune // wildcard character of this pattern Escape rune // escape character of this pattern; if available Needle Needle // NOTE: needle does not contain the Escape character Wildcard []bool // for every rune in Needle exists a wildcard bool HasWildcard bool // whether the Needle has at least one wildcard }
Pattern is string literal (of type Needle) with wildcards which can be escaped by Escape, use NoEscape to signal the absence of an escape character.
func DeEncodeContainsPatternCI ¶
DeEncodeContainsPatternCI de-encodes the provided string for usage with bcContainsPatternCi
func DeEncodeContainsPatternCS ¶
DeEncodeContainsPatternCS de-encodes the provided string for usage with bcContainsPatternCs
func DeEncodeContainsPatternUTF8CI ¶
DeEncodeContainsPatternUTF8CI de-encodes the provided string for usage with bcContainsPatternUTF8Ci
func NewPattern ¶
NewPattern creates a new Pattern for the provided string, wildcard and escape character. E.g. for "a@b_c@_d" with wildcard '_' and escape '@' a pattern is created with Pattern.Needle = "ab_c_d", and Pattern.Wildcard = [false, false, true, false, false, false]. Appreciate that the second wildcard is escaped and thus corresponds to the value true in the wildcard slice. NOTE: Pattern.WC and Pattern.Escape cannot be the same character.
type StrCmpType ¶
type StrCmpType int
const ( CS StrCmpType = iota CiASCII // case-insensitive on ASCII only CiUTF8 // case-insensitive all unicode code-points )
func (StrCmpType) String ¶
func (t StrCmpType) String() string