Added support for start-of-input (\A) and end-of-input (\Z) assertions

This commit is contained in:
2025-01-30 13:56:56 -05:00
parent db7c884b83
commit ee51e39d59
3 changed files with 24 additions and 2 deletions

View File

@@ -98,6 +98,13 @@ 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)
if inCharClass {
return postfixNode{}, fmt.Errorf("input boundaries are not allowed in character class")
} else {
toReturn.nodetype = assertionNode
toReturn.contents = append(toReturn.contents, c)
}
case 'n': // Newline character
toReturn.nodetype = characterNode
toReturn.contents = append(toReturn.contents, '\n')