"Kun" wrote: > i tried to parse (below) with the regular expression: emails = > re.findall('\S*\s([EMAIL PROTECTED])', senders) > > and got the following error: > > Traceback (most recent call last): > File "/Life/School/Homework/Spring 2006/OPIM > 399/Tutorial/IMAP/scannermailer.py", line 19, in -toplevel- > emails = re.findall('\S*\s([EMAIL PROTECTED])', senders) > File > "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/sre.py", > line 167, in findall > return _compile(pattern, flags).findall(string) > TypeError: expected string or buffer > > any help would be appreciated.
findall expects a string as the target, not a list of strings. you can either use a loop to apply the RE to each string fragment separately, or join the fragments into a single string before you pass it to re.findall. on the other hand, your data looks pretty regular. why not just loop over the fragments and look for things that start with "From:" ? </F> -- http://mail.python.org/mailman/listinfo/python-list