olebedev/when · casual_date.go
go logo
func regexContains(regex string, text string) bool {
	contains, _ := regexp.MatchString(regex, text)

	return contains
}
Similar code snippets
1.
hyperledger/burrow · filter.go
Match rating: 66.59% · 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))
}
2.
taskcluster/pulse-go · pulse.go
Match rating: 62.25% · See similar code snippets
go logo
func match(regex, text string) string {
	if matched, _ := regexp.MatchString(regex, text); matched {
		return regexp.MustCompile(regex).ReplaceAllString(text, "$1")
	}
	return ""
}
3.
rockneurotiko/go-tgbot · callbacktypes.go
Match rating: 61.02% · See similar code snippets
go logo
func (rc MultiRegexCommand) getRegexMatch(text string) (bool, *regexp.Regexp) {
	for _, r := range rc.Regex {
		if r.MatchString(text) {
			return true, r
		}
	}
	return false, nil
}
4.
choria-io/go-validator · regex.go
Match rating: 58.64% · 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
}
5.
danryan/hal · handler.go
Match rating: 58.41% · See similar code snippets
go logo
func handlerMatch(r *regexp.Regexp, text string) bool {
	if !r.MatchString(text) {
		return false
	}
	return true
}
6.
choria-io/go-choria · util.go
Match rating: 56.95% · 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
}
7.
zebresel-com/mongodm · validation.go
Match rating: 56.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
}
8.
rockneurotiko/go-tgbot · callbacktypes.go
Match rating: 54.73% · See similar code snippets
go logo
func (rc RegexCommand) canCall(text string) bool {
	return rc.Regex.MatchString(text)
}
9.
stretchr/testify · suite.go
Match rating: 54.49% · See similar code snippets
go logo
func methodFilter(name string) (bool, error) {
	if ok, _ := regexp.MatchString("^Test", name); !ok {
		return false, nil
	}
	return regexp.MatchString(*matchMethod, name)
}
10.
nbari/violetear · dynamic.go
Match rating: 54.14% · 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
}