Throw error if \B is used in character class

master
Aadhavan Srinivasan 3 days ago
parent 00c39857eb
commit b734d61a03

@ -95,6 +95,9 @@ func newEscapedNode(c rune, inCharClass bool) (postfixNode, error) {
toReturn.nodetype = assertionNode toReturn.nodetype = assertionNode
toReturn.contents = append(toReturn.contents, c) toReturn.contents = append(toReturn.contents, c)
} }
if c == 'B' && inCharClass { // Invalid
return postfixNode{}, fmt.Errorf("word boundaries are not allowed in character class")
}
case 'n': // Newline character case 'n': // Newline character
toReturn.nodetype = characterNode toReturn.nodetype = characterNode
toReturn.contents = append(toReturn.contents, '\n') toReturn.contents = append(toReturn.contents, '\n')

Loading…
Cancel
Save