package main import "regexp" func main() { f := func(pattern, s string) { switch b, err := regexp.Match(pattern, []byte(s)); err { case nil: { println("Got a match?", b) } default: { println("FAIL:", err.String()) } } } f("a+b", "a+b") f("a*b", "a*b") f("a?b", "a?b") f("+b", "+b") f("*b", "*b") f("?b", "?b") } /* OUTPUT: Got a match? false Got a match? true Got a match? true FAIL: closure applies to nothing FAIL: closure applies to nothing Got a match? true EXPECTED: Got a match? false Got a match? true Got a match? true FAIL: closure applies to nothing FAIL: closure applies to nothing FAIL: closure applies to nothing */