Documentation ¶
Index ¶
- Variables
- func CaptureString(b []byte, expr string) string
- func CaptureTime(b []byte, expr, layout string) (time.Time, error)
- func CaptureUint(b []byte, expr string) (uint, error)
- func FindStringSubmatchNamedMap(rx *regexp.Regexp, s string) map[string]string
- func McReplaceAllString(pattern string, s string, repl string) string
- func MustCaptureTime(b []byte, expr, layout string) time.Time
- func MustCaptureUint(b []byte, expr string) uint
- type RegexpSet
- func (set *RegexpSet) FindAllString(pattern string, s string, n int, useStore bool, key string) []string
- func (set *RegexpSet) FindAllStringSubmatch(pattern string, s string, n int, useStore bool, key string) [][]string
- func (set *RegexpSet) FindStringSubmatch(pattern string, s string, useStore bool, key string) []string
- func (set *RegexpSet) GetRegexp(pattern string, useStore bool, key string) *regexp.Regexp
- type StringMatcher
Constants ¶
This section is empty.
Variables ¶
var ErrMatchNotFound = errors.New("match not found")
Functions ¶
func CaptureString ¶ added in v0.47.0
CaptureString returns the first captured string.
func CaptureTime ¶ added in v0.47.0
func CaptureUint ¶ added in v0.47.0
CaptureUint requires first capture to be parseable by `strconv.Atoi` such as `[0-9]+`. Panics is capture is not parseable.
func McReplaceAllString ¶
McReplaceAllString is a single line MustCompile regexp for ReplaceAllString
func MustCaptureTime ¶ added in v0.47.0
func MustCaptureUint ¶ added in v0.47.0
MustCaptureUint will return `0` if match is not found. It will panic if strconv fails.
Types ¶
type RegexpSet ¶
RegexpSet is a struct that holds compiled regular expressions. Primary goals of this struct is to reduce MustCompile regular expressions into a single function call and to store the compiled regular expressions if desired
func NewRegexpSet ¶
func NewRegexpSet() RegexpSet
func (*RegexpSet) FindAllString ¶
func (*RegexpSet) FindAllStringSubmatch ¶
func (set *RegexpSet) FindAllStringSubmatch(pattern string, s string, n int, useStore bool, key string) [][]string
FindAllStringSubmatch performs a regular expression find against the supplied pattern and string. It will store the compiled regular expression for later use.
func (*RegexpSet) FindStringSubmatch ¶
type StringMatcher ¶
StringMatcher provides the ability to match a string against multiple regular expressions with a pre-formatting function as well.
func NewStringMatcher ¶
func NewStringMatcher() StringMatcher
NewStringMatcher returns a new StringMatcher instance.
func (*StringMatcher) AddMatcher ¶
func (sm *StringMatcher) AddMatcher(rx *regexp.Regexp)
AddMatcher adds a regular expression to attempt to match against.
func (*StringMatcher) Match ¶
func (sm *StringMatcher) Match(input string) bool
Match runs the provided string against the prematch function and regular expresssions, returning true if any of the expressions match.