How can this Perl regular expression be expressed in Python?
Gabriel Genellina
gagsl-py at yahoo.com.ar
Wed Feb 14 01:58:22 EST 2007
En Wed, 14 Feb 2007 04:11:37 -0300, John Nagle <nagle at animats.com>
escribió:
> Gabriel Genellina wrote:
>> En Wed, 14 Feb 2007 01:07:33 -0300, John Nagle <nagle at animats.com>
>> escribió:
>>
>>> Here's a large Perl regular expression, from a Perl address parser in
>>> CPAN:
>>>
>>> use re 'eval';
>>> $Addr_Match{street} = qr/
>>> (?:
>>> # special case for addresses like 100 South Street
>>> (?:($Addr_Match{direct})\W+ (?{ $_{street} = $^N
>>> })
>>> ($Addr_Match{type})\b (?{ $_{type} = $^N
>>> }))
> Incidentally, does anybody know what "$^N" means in Perl? That
> abbreviation isn't in the list of special variables.
From the context it appears to be the "last matched group", or something
like that... but best look for some authoritative answer.
--
Gabriel Genellina
More information about the Python-list
mailing list