Documentation ¶
Overview ¶
Package pattern handles parsing and matching SQL LIKE-style glob patterns.
Index ¶
Constants ¶
const (
DefaultEscapeChar = '\\'
)
Variables ¶
var ( ErrIllegalEscapeChar = verror.Register("v.io/v23/query/pattern.IllegalEscapeChar", verror.NoRetry, "{1:}{2:} '%' and '_' cannot be used as escape characters") ErrInvalidEscape = verror.Register("v.io/v23/query/pattern.InvalidEscape", verror.NoRetry, "{1:}{2:} only '%', '_', and the escape character are allowed to be escaped, found '\\{3}'") )
Functions ¶
func Escape ¶
Escape escapes a literal string for inclusion in a LIKE-style pattern assuming '\' as escape character. See EscapeWithEscapeChar().
func EscapeWithEscapeChar ¶
EscapeWithEscapeChar escapes a literal string for inclusion in a LIKE-style pattern. It inserts escChar before each '_', '%', and escChar in the string.
func NewErrIllegalEscapeChar ¶
NewErrIllegalEscapeChar returns an error with the ErrIllegalEscapeChar ID.
Types ¶
type Pattern ¶
type Pattern struct {
// contains filtered or unexported fields
}
Pattern is a parsed LIKE-style glob pattern.
func Parse ¶
Parse parses a LIKE-style glob pattern assuming '\' as escape character. See ParseWithEscapeChar().
func ParseWithEscapeChar ¶
ParseWithEscapeChar parses a LIKE-style glob pattern. Supported wildcards are '_' (match any one character) and '%' (match zero or more characters). They can be escaped by escChar; escChar can also escape itself. '_' and '%' cannot be used as escChar; '\x00' escChar disables escaping.
func (*Pattern) FixedPrefix ¶
FixedPrefix returns the unescaped fixed prefix that all matching strings must start with, and whether the prefix is the whole pattern.
func (*Pattern) MatchString ¶
MatchString returns true iff the pattern matches the entire string.