[Tutor] re.findall() weirdness.

Dan Tropp dan@webmind.com
Wed, 27 Jun 2001 10:59:52 +1000


I tried these in my python shell. Why do the last two give what they do?

>>> print re.findall('<.*?>','<a> </a> <a> </a>')
['<a>', '</a>', '<a>', '</a>']
>>> print re.findall('<.*?>','<1> </2> \n<3> </4>')
['<1>', '</2>', '<3>', '</4>']
>>> print re.findall('<.*?>','<1> </2> \n<3> </4>', re.I|re.S)
[]
>>> print re.findall('<.*?>','<1> </2> \n<3> </4>', re.I)
['</2>', '<3>', '</4>']
>>> 

Dan Tropp
Dept Psychology, University of Melbourne, Australia
ph:+61 3 8344 0396   fax:+61 3 9347 6618