MCPcopy
hub / github.com/stretchr/testify / matchRegexp

Function matchRegexp

assert/assertions.go:1704–1720  ·  view source on GitHub ↗

matchRegexp return true if a specified regexp matches a string.

(rx interface{}, str interface{})

Source from the content-addressed store, hash-verified

1702
1703// matchRegexp return true if a specified regexp matches a string.
1704func matchRegexp(rx interface{}, str interface{}) bool {
1705 var r *regexp.Regexp
1706 if rr, ok := rx.(*regexp.Regexp); ok {
1707 r = rr
1708 } else {
1709 r = regexp.MustCompile(fmt.Sprint(rx))
1710 }
1711
1712 switch v := str.(type) {
1713 case []byte:
1714 return r.Match(v)
1715 case string:
1716 return r.MatchString(v)
1717 default:
1718 return r.MatchString(fmt.Sprint(v))
1719 }
1720}
1721
1722// Regexp asserts that a specified regexp matches a string.
1723//

Callers 2

RegexpFunction · 0.85
NotRegexpFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected