mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
regexp/syntax: correctly print ^ BOL and $ EOL
Fixes #12980. Change-Id: I936db2f57f7c4dc80bb8ec32715c4c6b7bf0d708 Reviewed-on: https://go-review.googlesource.com/16112 Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
parent
0b55be1ba2
commit
3aa755b8fb
2 changed files with 4 additions and 4 deletions
|
|
@ -166,9 +166,9 @@ func writeRegexp(b *bytes.Buffer, re *Regexp) {
|
||||||
case OpAnyChar:
|
case OpAnyChar:
|
||||||
b.WriteString(`(?s:.)`)
|
b.WriteString(`(?s:.)`)
|
||||||
case OpBeginLine:
|
case OpBeginLine:
|
||||||
b.WriteRune('^')
|
b.WriteString(`(?m:^)`)
|
||||||
case OpEndLine:
|
case OpEndLine:
|
||||||
b.WriteRune('$')
|
b.WriteString(`(?m:$)`)
|
||||||
case OpBeginText:
|
case OpBeginText:
|
||||||
b.WriteString(`\A`)
|
b.WriteString(`\A`)
|
||||||
case OpEndText:
|
case OpEndText:
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@ var simplifyTests = []struct {
|
||||||
{`(ab)+`, `(ab)+`},
|
{`(ab)+`, `(ab)+`},
|
||||||
{`(ab)?`, `(ab)?`},
|
{`(ab)?`, `(ab)?`},
|
||||||
{`.`, `(?s:.)`},
|
{`.`, `(?s:.)`},
|
||||||
{`^`, `^`},
|
{`^`, `(?m:^)`},
|
||||||
{`$`, `$`},
|
{`$`, `(?m:$)`},
|
||||||
{`[ac]`, `[ac]`},
|
{`[ac]`, `[ac]`},
|
||||||
{`[^ac]`, `[^ac]`},
|
{`[^ac]`, `[^ac]`},
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue