import "github.com/fufuok/utils/xjson/match"
Package match provides a simple pattern matcher with unicode support.
- func Allowable(pattern string) (min, max string)
- func IsPattern(str string) bool
- func Match(str, pattern string) bool
- func MatchLimit(str, pattern string, maxcomp int) (matched, stopped bool)
func Allowable(pattern string) (min, max string)
Allowable parses the pattern and determines the minimum and maximum allowable values that the pattern can represent. When the max cannot be determined, 'true' will be returned for infinite.
func IsPattern(str string) bool
IsPattern returns true if the string is a pattern.
func Match(str, pattern string) bool
Match returns true if str matches pattern. This is a very simple wildcard match where '*' matches on any number characters and '?' matches on any one character.
pattern: { term } term: '*' matches any sequence of non-Separator characters '?' matches any single non-Separator character c matches character c (c != '*', '?', '\\') '\\' c matches character c
func MatchLimit(str, pattern string, maxcomp int) (matched, stopped bool)
MatchLimit is the same as Match but will limit the complexity of the match operation. This is to avoid long running matches, specifically to avoid ReDos attacks from arbritary inputs.
How it works: The underlying match routine is recursive and may call itself when it encounters a sandwiched wildcard pattern, such as: `user:*:name`. Everytime it calls itself a counter is incremented. The operation is stopped when counter > maxcomp*len(str).
Generated by gomarkdoc