This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author davidchambers
Recipients davidchambers, ezio.melotti, mrabarnett, verdy_p
Date 2010-04-01.10:55:12
SpamBayes Score 1.7055632e-05
Marked as misclassified No
Message-id <1270119314.66.0.353276479542.issue7132@psf.upfronthosting.co.za>
In-reply-to
Content
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')
History
Date User Action Args
2010-04-01 10:55:15davidchamberssetrecipients: + davidchambers, ezio.melotti, mrabarnett, verdy_p
2010-04-01 10:55:14davidchamberssetmessageid: <1270119314.66.0.353276479542.issue7132@psf.upfronthosting.co.za>
2010-04-01 10:55:13davidchamberslinkissue7132 messages
2010-04-01 10:55:12davidchamberscreate