regexp: implement backtracking with pcre fallback Go's current regular expression package doesn't support all popular patterns which programmers from other languages have come to expect. Notably, the Go regexp package doesn’t implement the useful backreference functionality. Without that, users can't match "catcat" or "dogdog" with (cat|dog)\1 and would need to otherwise fall back to writing multiple lines of code, possibly involving an "if" statement. To permit more expressiveness than Go's strictly "regular" regular expressions, this change permits falling back to the wildly popular PCRE library when Go would previously return a compile error. This permits programmers to copy-paste common regular expressions from forum sites, stackoverflow, etc. and rest assured that they'll work as they would have in PHP or Ruby. Go shouldn't let ideological fundamentalism about algorithmic purity limit user adoption. Thanks to Florian Wiemer for his work on the pcre package which is now promoted to the core library. This CL doesn't yet implement Perl's (?{ code }) construct. A future CL will bring Campher into the core, permitting calling into Perl from Go regular expressions. Fixes issue 3451

Total comments: 2

Total comments: 7

Created: 8 years, 6 months ago [tar.bz2] Download [raw] Unified diffs Side-by-side diffs Delta from patch set Stats (+505 lines, -3 lines) Patch M src/cmd/api/goapi.go View 1 1 chunk +3 lines, -0 lines 0 comments Download M src/pkg/go/build/deps_test.go View 1 1 chunk +1 line, -1 line 0 comments Download M src/pkg/regexp/exec.go View 1 1 chunk +3 lines, -0 lines 0 comments Download A src/pkg/regexp/fallback.go View 1 1 chunk +86 lines, -0 lines 1 comment Download M src/pkg/regexp/find_test.go View 1 2 chunks +18 lines, -0 lines 0 comments Download A src/pkg/regexp/pcre/pcre.go View 1 1 chunk +384 lines, -0 lines 4 comments Download M src/pkg/regexp/regexp.go View 1 4 chunks +10 lines, -2 lines 2 comments Download

Total messages: 12