matchRegexp return true if a specified regexp matches a string.
(rx interface{}, str interface{})
| 1615 | |
| 1616 | // matchRegexp return true if a specified regexp matches a string. |
| 1617 | func matchRegexp(rx interface{}, str interface{}) bool { |
| 1618 | |
| 1619 | var r *regexp.Regexp |
| 1620 | if rr, ok := rx.(*regexp.Regexp); ok { |
| 1621 | r = rr |
| 1622 | } else { |
| 1623 | r = regexp.MustCompile(fmt.Sprint(rx)) |
| 1624 | } |
| 1625 | |
| 1626 | return (r.FindStringIndex(fmt.Sprint(str)) != nil) |
| 1627 | |
| 1628 | } |
| 1629 | |
| 1630 | // Regexp asserts that a specified regexp matches a string. |
| 1631 | // |