2017-04-27 32 views
-1

我想提取所有收到電子郵件的電子郵件。我用這個正則表達式在To後面提取電子郵件,它只是提取第一封電子郵件。使用正則表達式使用python 2.7提取電子郵件接收器

To: ([a-z0-9_\.-][email protected][\da-z\.-]+\.[a-z\.]{2,6}) 

而且當我使用這個正則表達式時沒有To。它爲收件人和發件人提取所有電子郵件。

([a-z0-9_\.-][email protected][\da-z\.-]+\.[a-z\.]{2,6}) 

這是數據的樣本

Message-ID: <[email protected]> 
    Date: Mon, 31 Dec 2001 10:53:43 -0800 (PST) 
    From: [email protected] 
    To: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected] 

謝謝

+0

參見[使用Python解析電子郵件(HTTP:/ /stackoverflow.com/questions/3050298/parsing-email-with-python)。 –

回答

0

嘗試使用類似:

emails = re.findall('write your expression there', emailDataText) 
相關問題