diff --git a/regex/compile.go b/regex/compile.go index eb78a93..b40c371 100644 --- a/regex/compile.go +++ b/regex/compile.go @@ -966,9 +966,9 @@ func thompson(re []postfixNode) (Reg, error) { s.groupNum = lparenNode.groupNum to_add := concatenate(lparenNode, s) nfa = append(nfa, to_add) - } else if middleNode.groupBegin && len(middleNode.transitions) == 0 { // The middle node is a lone lparen - something like '(())', and I'm looking at the first closing parentheses - nfa = append(nfa, lparenNode) - s.groupNum = middleNode.groupNum // In this case, the 'middle' node is actually a paren node + } else if middleNode.groupBegin && len(middleNode.transitions) == 0 { // The middle node is a lone lparen - something like '(())', and I'm looking at the first rparen + nfa = append(nfa, lparenNode) // I shouldn't have popped this out, because it is not involved in the current capturing group + s.groupNum = middleNode.groupNum // In this case, the 'middle' node is actually an lparen to_add := concatenate(middleNode, s) nfa = append(nfa, to_add) } else {