regexp: add HasMeta and regexp.Expr().
The former is a boolean function to test whether a string
contains a regular expression metacharacter; the second
returns the string used to compile the regexp.
R=gri, rsc
CC=golang-dev
https://golang.org/cl/3728041
diff --git a/src/pkg/regexp/find_test.go b/src/pkg/regexp/find_test.go
index 07f5586..27c5a54 100644
--- a/src/pkg/regexp/find_test.go
+++ b/src/pkg/regexp/find_test.go
@@ -119,7 +119,11 @@
func TestFind(t *testing.T) {
for _, test := range findTests {
- result := MustCompile(test.pat).Find([]byte(test.text))
+ re := MustCompile(test.pat)
+ if re.Expr() != test.pat {
+ t.Errorf("Expr() = `%s`; should be `%s`", re.Expr(), test.pat)
+ }
+ result := re.Find([]byte(test.text))
switch {
case len(test.matches) == 0 && len(result) == 0:
// ok