Documentation ¶
Index ¶
- type RegexpList
- type RegexpMap
- func (m *RegexpMap) Add(reStr string, lookupValue string) error
- func (m *RegexpMap) GetPrecompiledRegexp(reStr string) (re *regexp.Regexp)
- func (m *RegexpMap) LookupContainsValue(lookupKey, expectedValue string) (found bool)
- func (m *RegexpMap) LookupValues(lookupKey string) (lookupValues []string)
- func (m *RegexpMap) Remove(reStr, lookupValue string) (deleted bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RegexpList ¶ added in v1.6.0
type RegexpList []string
RegexpList is a utility struct that keeps an array of strings sorted by length
func NewRegexpList ¶ added in v1.6.0
func NewRegexpList(initialValues ...string) (result *RegexpList)
NewRegexpList returns a new RegexpList, if any initialValues is in place will add into the utility.
func (*RegexpList) Add ¶ added in v1.6.0
func (r *RegexpList) Add(val string)
Add function adds a new item in the list and sort the data based on the length
func (*RegexpList) Get ¶ added in v1.6.0
func (r *RegexpList) Get() []string
Get return an array of strings ordered by string len
func (*RegexpList) Len ¶ added in v1.6.0
func (r *RegexpList) Len() int
Len returns the len of the internal array.
func (*RegexpList) Remove ¶ added in v1.6.0
func (r *RegexpList) Remove(val string)
Remove removes the item from the internal array and keep the data sorted
type RegexpMap ¶
type RegexpMap struct {
// contains filtered or unexported fields
}
RegexpMap is a map-like type that allows lookups to match regexp keys. These keys are managed internally as strings, and are uniqued by this representation (and not recompiled on repeat inserts). Stored values are strings and are returned as-is, with the exception that repeat inserts of the same value are de-duped. Note: RegexpMap is not thread-safe and managing concurrent access is the responsibility of the callers.
func (*RegexpMap) Add ¶
Add associates a Regular expression to a lookupValue that will be used in the lookup functions. It will return an error and data will be not saved if the regexp does not compile correctly
func (*RegexpMap) GetPrecompiledRegexp ¶
GetPrecompiledRegexp returns the regexp matching reStr if it is in the map. This is a utility function to avoid recompiling regexps repeatedly, and the RegexpMap keeps the refcount for us.
func (*RegexpMap) LookupContainsValue ¶
LookupContainsValue returns true if any reStr in lookups, inserted via Add, matches lookupKey AND has a lookupValue, inserted via the same Add, that matches expectedValue.
func (*RegexpMap) LookupValues ¶
LookupValues returns all lookupValues, inserted via Add, where the reStr matches lookupKey