Author davidchambers
Recipients davidchambers, ezio.melotti, mrabarnett, verdy_p
Date 2010-04-01.10:55:12
SpamBayes Score 1.70556e-05
Marked as misclassified No
Message-id <>
I would find this functionality very useful. While I agree that it's often simpler to extract the relevant information in several steps, there are situations in which I'd prefer to do it all in one go.

The application I'm writing at the moment needs to extract metadata from text files. This metadata actually appears as text at the top of each file. For example:

title: Example title
tags: Django, Python, regular expressions

Example title

Here is the first paragraph.

I had expected something like this to get the job done:

meta = re.match(r'(?ms)(?:^(\S+):\s*(.*?)$\n)+^\s*$', contents_of_file)

Ideally in this case, meta.groups() would return:

('title', 'Example title', 'tags', 'Django, Python, regular expressions')
Date User Action Args
2010-04-01 10:55:15davidchamberssetrecipients: + davidchambers, ezio.melotti, mrabarnett, verdy_p
2010-04-01 10:55:14davidchamberssetmessageid: <>
2010-04-01 10:55:13davidchamberslinkissue7132 messages
2010-04-01 10:55:12davidchamberscreate