Why this result with the re module

Yingjie Lan lanyjie at yahoo.com
Tue Nov 2 05:31:12 CET 2010

Hi, I am rather confused by these results below. 
I am not a re expert at all. the module version 
of re is 2.2.1 with python 3.1.2

>>> import re
>>> re.findall('.a.', 'Mary has a lamb') #OK
['Mar', 'has', ' a ', 'lam'] 
>>> re.findall('(.a.)*', 'Mary has a lamb') #??
['Mar', '', '', 'lam', '', '']
>>> re.findall('(.a.)+', 'Mary has a lamb') #??
['Mar', 'lam']

Thanks in advance for any comments.



More information about the Python-list mailing list