diff --git a/postfixNode.go b/postfixNode.go index b8318f8..2809b45 100644 --- a/postfixNode.go +++ b/postfixNode.go @@ -116,6 +116,13 @@ func newEscapedNode(c rune, inCharClass bool) (postfixNode, error) { case 'v': // Vertical tab toReturn.nodetype = CHARACTER toReturn.contents = append(toReturn.contents, rune(11)) + case '-': // Literal hyphen - only in character class + if inCharClass { + toReturn.nodetype = CHARACTER + toReturn.contents = append(toReturn.contents, '-') + } else { + return postfixNode{}, fmt.Errorf("Invalid escape character.") + } default: // None of the above - append it as a regular character if isNormalChar(c) { // Normal characters cannot be escaped return postfixNode{}, fmt.Errorf("Invalid escape character.")