regexp: allow escaping of any punctuation
More in line with other regexp packages
and egrep; accommodates overzealous escapers.
R=r
CC=golang-dev
https://golang.org/cl/1008041
diff --git a/src/pkg/regexp/all_test.go b/src/pkg/regexp/all_test.go
index c1f6795..62dad3a 100644
--- a/src/pkg/regexp/all_test.go
+++ b/src/pkg/regexp/all_test.go
@@ -28,6 +28,7 @@
`[abc]`,
`[^1234]`,
`[^\n]`,
+ `\!\\`,
}
type stringError struct {
@@ -100,6 +101,14 @@
// fixed bugs
tester{`ab$`, "cab", vec{1, 3}},
tester{`axxb$`, "axxcb", vec{}},
+
+ // can backslash-escape any punctuation
+ tester{`\!\"\#\$\%\&\'\(\)\*\+\,\-\.\/\:\;\<\=\>\?\@\[\\\]\^\_\{\|\}\~`,
+ `!"#$%&'()*+,-./:;<=>?@[\]^_{|}~`, vec{0, 31}},
+ tester{`[\!\"\#\$\%\&\'\(\)\*\+\,\-\.\/\:\;\<\=\>\?\@\[\\\]\^\_\{\|\}\~]+`,
+ `!"#$%&'()*+,-./:;<=>?@[\]^_{|}~`, vec{0, 31}},
+ tester{"\\`", "`", vec{0, 1}},
+ tester{"[\\`]+", "`", vec{0, 1}},
}
func compileTest(t *testing.T, expr string, error os.Error) *Regexp {