Description
Based on the discussion on rust-lang/regex#955, it seems that many regexp sources refer only to (?expr) for capturing group names, and at least a couple regexp implementations only support that form. Go, following RE2, only supports (?Pexpr). The original comment I wrote for RE2 says:
// Check for named captures, first introduced in Python's regexp library.
// As usual, there are three slightly different syntaxes:
//
// (?P<name>expr) the original, introduced by Python
// (?<name>expr) the .NET alteration, adopted by Perl 5.10
// (?'name'expr) another .NET alteration, adopted by Perl 5.10
//
// Perl 5.10 gave in and implemented the Python version too,
// but they claim that the last two are the preferred forms.
// PCRE and languages based on it (specifically, PHP and Ruby)
// support all three as well. EcmaScript 4 uses only the Python form.
//
// In both the open source world (via Code Search) and the
// Google source tree, (?P<expr>name) is the dominant form,
// so that's the one we implement. One is enough.
Given the widespread usage and documentation, I am now inclined to accept (?expr) as well. There seems to be very little usage of (?'name'expr) so that one would still be rejected.
There would be no change to the data structures, only to the syntax accepted. (Go's regexp/syntax does not guarantee to round trip back to the exact same string.)
I talked to RE2 maintainer @junyer and he agreed to make the change in RE2 if Go does, which will help keep Go, RE2, and RE2/J in sync.
It also sounds like @BurntSushi is moving toward making the same change for Rust. It is not a goal for Rust and Go to exactly match, but it is more evidence for the decision.