returning all matching groups with re.search()

Mauro Caceres mauro.caceres at gmail.com
Mon Feb 7 11:26:33 EST 2011


>>> import re
>>> help(re.findall)
Help on function findall in module re:

findall(pattern, string, flags=0)
    Return a list of all non-overlapping matches in the string.

    If one or more groups are present in the pattern, return a
    list of groups; this will be a list of tuples if the pattern
    has more than one group.

    Empty matches are included in the result.

>>> re.findall('e','fredbarneybettywilma')
['e', 'e', 'e']

-- 
Mauro Cáceres
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110207/95b246a3/attachment-0001.html>


More information about the Python-list mailing list