From 7431b1a7b2a5a5b796213bad72145254f6fcd3ee Mon Sep 17 00:00:00 2001 From: Aadhavan Srinivasan Date: Thu, 30 Jan 2025 15:08:18 -0500 Subject: [PATCH] Changed \Z to \z to fit with Go's naming --- regex/compile.go | 2 +- regex/postfixNode.go | 2 +- regex/re_test.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/regex/compile.go b/regex/compile.go index f858076..3be2477 100644 --- a/regex/compile.go +++ b/regex/compile.go @@ -880,7 +880,7 @@ func thompson(re []postfixNode) (Reg, error) { stateToAdd.assert = nonwboundAssert case 'A': stateToAdd.assert = soiAssert - case 'Z': + case 'z': stateToAdd.assert = eoiAssert } } else { // Lookaround diff --git a/regex/postfixNode.go b/regex/postfixNode.go index 47f8c48..c60de47 100644 --- a/regex/postfixNode.go +++ b/regex/postfixNode.go @@ -98,7 +98,7 @@ func newEscapedNode(c rune, inCharClass bool) (postfixNode, error) { if c == 'B' && inCharClass { // Invalid return postfixNode{}, fmt.Errorf("word boundaries are not allowed in character class") } - case 'A', 'Z': // A is start of input, Z is end of input (regardless of RE_MULTILINE) + case 'A', 'z': // A is start of input, z is end of input (regardless of RE_MULTILINE) if inCharClass { return postfixNode{}, fmt.Errorf("input boundaries are not allowed in character class") } else { diff --git a/regex/re_test.go b/regex/re_test.go index 3e07024..80ba6e9 100644 --- a/regex/re_test.go +++ b/regex/re_test.go @@ -446,8 +446,8 @@ var reTests = []struct { {`\A`, []ReFlag{RE_MULTILINE}, "jkl\n123abc\nxyz", []Group{{0, 0}}}, {`$`, nil, "jkl\n123abc\nxyz", []Group{{14, 14}}}, {`$`, []ReFlag{RE_MULTILINE}, "jkl\n123abc\nxyz", []Group{{3, 3}, {10, 10}, {14, 14}}}, - {`\Z`, []ReFlag{RE_MULTILINE}, "jkl\n123abc\nxyz", []Group{{14, 14}}}, - {`^abc\Z`, []ReFlag{RE_MULTILINE}, "abc\nabc\nabc", []Group{{8, 11}}}, + {`\z`, []ReFlag{RE_MULTILINE}, "jkl\n123abc\nxyz", []Group{{14, 14}}}, + {`^abc\z`, []ReFlag{RE_MULTILINE}, "abc\nabc\nabc", []Group{{8, 11}}}, {`a.b`, nil, "a\nb", []Group{}}, {`a.b`, []ReFlag{RE_SINGLE_LINE}, "a\nb", []Group{{0, 3}}},