Is it possible to perform a named-group match in Perl\'s regex syntax as with Python\'s? I always bind the $n
values to proper names after matching, so I\'d fin
As of Perl 5.10, Perl regexes support some Python features, making them Python compatible regexes, I guess. The Python versions have the "P" in them, but all of these work in Perl 5.10. See the perlre documentation for the details:
Define a named capture buffer. Equivalent to (?
.
(?Ppattern)
Backreference to a named capture buffer. Equivalent to \g{NAME}
.
(?P=NAME)
Subroutine call to a named capture buffer. Equivalent to (?&NAME)
.
(?P>NAME)
Although I didn't add the Python-compatibility to the latest edition of Learning Perl, we do cover the new Perl 5.10 features, including named captures.