473,387 Members | 1,318 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Re: Parsing Email 'References' header.

On Thu, May 8, 2008 at 2:53 PM, Aspersieman <as*********@gmail.comwrote:
Hi

I have a python script that parses email headers to extract information
from them. I need to get the _last_ messageid in the 'References' field
(http://cr.yp.to/immhf/thread.html) to create a threaded view of these
emails (these messageid's are stored in a database).

Now, I can easily access the 'References' field using the python 'email'
module, but I need a regular expression to get the last messageid in the
'References' field.

Here's what I have so far:
<code>
rx_lastmesgid = re.compile(r"(<.+>$)")
lastmesgid = "".join( filter( rx_lastmesgid.match, parentid ) ) #
parentid's value is
eg:"<1@mail.gmail.com><2@mail.gmail.com><3@mail.gm ail.com><4@mail.gmail.com><5@mail.gmail.com>"
lastmesgid = "".join( filter( rx_lastmesgid.match, parentid ) )
</code>

I need it to return "<5@mail.gmail.com>"

Can anyone help?
"<.*>(<.*?>)"
Jun 27 '08 #1
0 1057

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Omkar Singh | last post by:
I try to parse a XML document containg some references using XmlDocument Class' method GetElementbyTagName. It just give the content between starting tagName and ending tagName but not all...
9
by: Omkar Singh | last post by:
I try to parse a XML document containg some references using XmlDocument Class' method GetElementbyTagName. It just give the content between starting tagName and ending tagName but not all...
0
by: Aspersieman | last post by:
Hi I have a python script that parses email headers to extract information from them. I need to get the _last_ messageid in the 'References' field (http://cr.yp.to/immhf/thread.html) to create a...
0
by: J. Cliff Dyer | last post by:
On Thu, 2008-05-08 at 14:53 +0200, Aspersieman wrote: Forget regular expressions. py>>lastmesgid = '<' + parentid.split('<')
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.