On 16.05.2011 18:25, Tracubik wrote:
pls help me fixing this:
import re
s = "linka la baba"
re_s = re.compile(r'(link|l)a' , re.IGNORECASE)
print re_s.findall(s)
output:
['link', 'l']
why?
As the docs say:
"If one or more groups are present in the pattern, return a list of
groups;"
http://docs.python.org/library/re.html?highlight=findall#re.findall
i want my re_s to find linka and la, he just find link and l and forget
about the ending a.
Try with non-grouping parentheses:
re_s = re.compile(r'(?:link|l)a' , re.IGNORECASE)
--
http://mail.python.org/mailman/listinfo/python-list