cespare/reflex · match.go
go logo
func newRegexMatcher(regex *regexp.Regexp, inverse bool) *regexMatcher {
	return &regexMatcher{
		regex:   regex,
		inverse: inverse,
		mu:      new(sync.Mutex),
	}
}
Similar code snippets
1.
mikespook/possum · regex.go
Match rating: 58.09% · See similar code snippets
go logo
func RegEx(path string) *regex {
	r, err := regexp.Compile(path)
	if err != nil {
		panic(err)
	}
	return &regex{
		r: r,
	}
}
2.
choria-io/go-choria · util.go
Match rating: 56.75% · See similar code snippets
go logo
func MatchAnyRegex(str []byte, regex []string) bool {
	for _, reg := range regex {
		if matched, _ := regexp.Match(reg, str); matched {
			return true
		}
	}

	return false
}
3.
hyperledger/burrow · filter.go
Match rating: 56.46% · See similar code snippets
go logo
func match(regex *regexp.Regexp, text *string) bool {
	// Always match on a nil regex (indicating no constraint on text),
	// and otherwise never match on nil text (indicating a non-string convertible type)
	return regex == nil || (text != nil && regex.MatchString(*text))
}
4.
prometheus/prometheus · relabel.go
Match rating: 56.27% · See similar code snippets
go logo
func NewRegexp(s string) (Regexp, error) {
	regex, err := regexp.Compile("^(?:" + s + ")$")
	return Regexp{
		Regexp:   regex,
		original: s,
	}, err
}
5.
zebresel-com/mongodm · validation.go
Match rating: 55.32% · See similar code snippets
go logo
func validateRegexp(regex string, target string) bool {

	match, err := regexp.MatchString(regex, target)

	if err != nil {
		fmt.Println("%v", err)
	}

	return match
}
6.
onsi/gomega · matchers.go
Match rating: 55.18% · See similar code snippets
go logo
func MatchRegexp(regexp string, args ...interface{}) types.GomegaMatcher {
	return &matchers.MatchRegexpMatcher{
		Regexp: regexp,
		Args:   args,
	}
}
7.
prometheus/tsdb · selector.go
Match rating: 55.17% · See similar code snippets
go logo
func NewRegexpMatcher(name, pattern string) (Matcher, error) {
	re, err := regexp.Compile(pattern)
	if err != nil {
		return nil, err
	}
	return &regexpMatcher{name: name, re: re}, nil
}
8.
choria-io/go-validator · regex.go
Match rating: 54.75% · See similar code snippets
go logo
func ValidateString(input string, regex string) (bool, error) {
	re, err := regexp.Compile(regex)
	if err != nil {
		return false, fmt.Errorf("invalid regex '%s'", regex)
	}

	if !re.MatchString(input) {
		return false, fmt.Errorf("input does not match '%s'", regex)
	}

	return true, nil
}
9.
nbari/violetear · dynamic.go
Match rating: 54.2% · See similar code snippets
go logo
func (d dynamicSet) Set(name, regex string) error {
	if !strings.HasPrefix(name, ":") {
		return errors.New("dynamic route name must start with a colon ':'")
	}

	// fix regex
	if !strings.HasPrefix(regex, "^") {
		regex = fmt.Sprintf("^%s$", regex)
	}

	r := regexp.MustCompile(regex)
	d[name] = r

	return nil
}
10.
cloudfoundry-community/go-cfenv · service.go
Match rating: 54.14% · See similar code snippets
go logo
func (s *Services) match(matcher, content string) bool {
	regex, err := regexp.Compile("(?i)^" + matcher + "$")
	if err != nil {
		return false
	}
	return regex.MatchString(content)
}