5 "github.com/onsi/gomega/format"
9 type MatchRegexpMatcher struct {
14 func (matcher *MatchRegexpMatcher) Match(actual interface{}) (success bool, err error) {
15 actualString, ok := toString(actual)
17 return false, fmt.Errorf("RegExp matcher requires a string or stringer.\nGot:%s", format.Object(actual, 1))
20 match, err := regexp.Match(matcher.regexp(), []byte(actualString))
22 return false, fmt.Errorf("RegExp match failed to compile with error:\n\t%s", err.Error())
28 func (matcher *MatchRegexpMatcher) FailureMessage(actual interface{}) (message string) {
29 return format.Message(actual, "to match regular expression", matcher.regexp())
32 func (matcher *MatchRegexpMatcher) NegatedFailureMessage(actual interface{}) (message string) {
33 return format.Message(actual, "not to match regular expression", matcher.regexp())
36 func (matcher *MatchRegexpMatcher) regexp() string {
38 if len(matcher.Args) > 0 {
39 re = fmt.Sprintf(matcher.Regexp, matcher.Args...)