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/all_test.go b/src/pkg/regexp/all_test.go
index d5a0e7d..5b614de 100644
--- a/src/pkg/regexp/all_test.go
+++ b/src/pkg/regexp/all_test.go
@@ -269,6 +269,18 @@
 	}
 }
 
+func TestHasMeta(t *testing.T) {
+	for _, tc := range quoteMetaTests {
+		// HasMeta should be false if QuoteMeta returns the original string;
+		// true otherwise.
+		quoted := QuoteMeta(tc.pattern)
+		if HasMeta(tc.pattern) != (quoted != tc.pattern) {
+			t.Errorf("HasMeta(`%s`) = %t; want %t",
+				tc.pattern, HasMeta(tc.pattern), quoted != tc.pattern)
+		}
+	}
+}
+
 type numSubexpCase struct {
 	input    string
 	expected int