MCPcopy Create free account
hub / github.com/stretchr/testify / matchRegexp

Function matchRegexp

assert/assertions.go:1654–1671  ·  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

1652
1653// matchRegexp return true if a specified regexp matches a string.
1654func matchRegexp(rx interface{}, str interface{}) bool {
1655 var r *regexp.Regexp
1656 if rr, ok := rx.(*regexp.Regexp); ok {
1657 r = rr
1658 } else {
1659 r = regexp.MustCompile(fmt.Sprint(rx))
1660 }
1661
1662 switch v := str.(type) {
1663 case []byte:
1664 return r.Match(v)
1665 case string:
1666 return r.MatchString(v)
1667 default:
1668 return r.MatchString(fmt.Sprint(v))
1669 }
1670
1671}
1672
1673// Regexp asserts that a specified regexp matches a string.
1674//

Callers 2

RegexpFunction · 0.85
NotRegexpFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected