golang/go

regexp: considers "\Q\E*" as valid regexp

dvyukov opened this issue · 4 comments

Regexp package successfully compiles "\Q\E_", while re2 says:
re2/re2.cc:202: Error parsing '\Q\E_': no argument for repetition operator: *

Who is right here? What is the reason for difference?

go version devel +b0532a9 Mon Jun 8 05:13:15 2015 +0000 linux/amd64

Similar case is "\Q\E{2}"

rsc commented

Perl and RE2 both reject \Q\E*, so I suppose Go should too, although I don't see how it is really different from (?:)*.

rsc commented

Now I see it. (?:) is a group.

CL https://golang.org/cl/17233 mentions this issue.