"<" special character in re?

Kragen Sitaker kragen at dnaco.net
Tue Sep 19 16:35:15 EDT 2000


In article <8FB39D54Astefanwitzelzvwunigo at 134.76.98.67>,
Stefan Witzel <stefan.witzel at zvw.uni-goettingen.de> wrote:
>When I try to extract all characters between "<" and ">" using re ...
>   hit = re.match('<(?P<i>[a-z]*)>', 'ab<cd>ef')
>
>... I always get "no hit". Is "<" a special character in re? 

No, but what is your expression trying to match?  It looks for all the
world like a syntactically invalid regex.  It would seem you could use
'<([^>]*)>' to match what you say you want to match.  What is the ?P<i>
stuff supposed to mean?
-- 
<kragen at pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Perilous to all of us are the devices of an art deeper than we ourselves
possess.
                -- Gandalf the Grey [J.R.R. Tolkien, "Lord of the Rings"]



More information about the Python-list mailing list