Commit 3aa755b8 authored by Tamir Duberstein's avatar Tamir Duberstein Committed by Russ Cox

regexp/syntax: correctly print `^` BOL and `$` EOL

Fixes #12980.

Change-Id: I936db2f57f7c4dc80bb8ec32715c4c6b7bf0d708
Reviewed-on: https://go-review.googlesource.com/16112Reviewed-by: default avatarRuss Cox <rsc@golang.org>
parent 0b55be1b
...@@ -166,9 +166,9 @@ func writeRegexp(b *bytes.Buffer, re *Regexp) { ...@@ -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 { ...@@ -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]`},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment