summaryrefslogtreecommitdiff
path: root/src/pkg/regexp/regexp.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2010-04-26 10:00:18 -0700
committerRuss Cox <rsc@golang.org>2010-04-26 10:00:18 -0700
commitf31065a8707a5807d01c855ba867131a104d2a5d (patch)
tree0e1343518ff55e5bde3b0313de563ec0f283d85f /src/pkg/regexp/regexp.go
parent1d46a6979a3969fd39274f67a80a3dc3fa90797c (diff)
downloadgolang-f31065a8707a5807d01c855ba867131a104d2a5d.tar.gz
regexp: allow escaping of any punctuation
More in line with other regexp packages and egrep; accommodates overzealous escapers. R=r CC=golang-dev http://codereview.appspot.com/1008041
Diffstat (limited to 'src/pkg/regexp/regexp.go')
-rw-r--r--src/pkg/regexp/regexp.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/pkg/regexp/regexp.go b/src/pkg/regexp/regexp.go
index f8d03d743..cdd5cacdd 100644
--- a/src/pkg/regexp/regexp.go
+++ b/src/pkg/regexp/regexp.go
@@ -298,8 +298,8 @@ func special(c int) bool {
return false
}
-func specialcclass(c int) bool {
- for _, r := range `\-[]` {
+func ispunct(c int) bool {
+ for _, r := range "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~" {
if c == r {
return true
}
@@ -344,7 +344,7 @@ func (p *parser) charClass() instr {
p.error(ErrExtraneousBackslash)
case c == 'n':
c = '\n'
- case specialcclass(c):
+ case ispunct(c):
// c is as delivered
default:
p.error(ErrBadBackslash)
@@ -439,7 +439,7 @@ func (p *parser) term() (start, end instr) {
p.error(ErrExtraneousBackslash)
case c == 'n':
c = '\n'
- case special(c):
+ case ispunct(c):
// c is as delivered
default:
p.error(ErrBadBackslash)