Some more odd behaviour from the Regexp library
see at sig.for.address.edu
Thu Oct 20 05:31:51 CEST 2005
In article <1129777843.892280.302490 at g44g2000cwa.googlegroups.com>,
"David Veerasingam" <vdavidster at gmail.com> wrote:
> Can anyone explain why it won't give me my captured group?
> In : a = 'exit: gkdfjgfjdfsgdjglkghdfgkd'
> In : import re
> In : b = re.search(r'exit: (.*?)', a)
> In : b.group(0)
> Out: 'exit: '
> In : b.group(1)
> Out: ''
> In : b.group(2)
> IndexError: no such group
The ? tells (.*?) to match as little as possible and that is nothing.
If you change it to (.*) it should do what you want.
Make obvious changes to get real email address.
More information about the Python-list