Why this result with the re module

Discussion in 'Python' started by Yingjie Lan, Nov 2, 2010.

  1. Yingjie Lan

    Yingjie Lan Guest

    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.

    Yingjie
     
    Yingjie Lan, Nov 2, 2010
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    933
    Mark Rae
    Dec 21, 2006
  2. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,124
    Smokey Grindel
    Dec 2, 2006
  3. J.Ram
    Replies:
    7
    Views:
    668
  4. Pavel
    Replies:
    7
    Views:
    556
    Pavel
    Sep 19, 2010
  5. Michael Tan
    Replies:
    32
    Views:
    1,046
    Ara.T.Howard
    Jul 21, 2005
Loading...

Share This Page