From 3e178e74fd2896c4ee73e317a4229e11beb5c651 Mon Sep 17 00:00:00 2001 From: Brandon Dyck Date: Tue, 10 Sep 2024 18:39:54 -0600 Subject: [PATCH] Check both beginning-of-text conditions in Regexp --- bytes/regexp.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bytes/regexp.go b/bytes/regexp.go index 45a558a..a8b14c4 100644 --- a/bytes/regexp.go +++ b/bytes/regexp.go @@ -41,7 +41,7 @@ func (rr *RuneReader) Cursor() cursor.Cursor[byte] { } func Regexp(str string) gigaparsec.Parser[byte, []byte] { - if !strings.HasPrefix(str, "^") { + if !strings.HasPrefix(str, "^") && !strings.HasPrefix(str, `\A`) { str = "^" + str } re := regexp.MustCompile(str)