David Chambers <[email protected]> added the comment:
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')
----------
nosy: +davidchambers
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue7132>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com