regexputil

package
v0.29.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 26, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindStringSubmatchNamedMap

func FindStringSubmatchNamedMap(rx *regexp.Regexp, s string) map[string]string

func McReplaceAllString

func McReplaceAllString(pattern string, s string, repl string) string

McReplaceAllString is a single line MustCompile regexp for ReplaceAllString

Types

type RegexpSet

type RegexpSet struct {
	Regexps map[string]*regexp.Regexp
}

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 (set *RegexpSet) FindAllString(pattern string, s string, n int, useStore bool, key string) []string

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

func (set *RegexpSet) FindStringSubmatch(pattern string, s string, useStore bool, key string) []string

func (*RegexpSet) GetRegexp

func (set *RegexpSet) GetRegexp(pattern string, useStore bool, key string) *regexp.Regexp

type StringMatcher

type StringMatcher struct {
	Matchers []*regexp.Regexp
	PreMatch func(string) string
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL