Message102080
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:15 | davidchambers | set | recipients:
+ davidchambers, ezio.melotti, mrabarnett, verdy_p |
2010-04-01 10:55:14 | davidchambers | set | messageid: <1270119314.66.0.353276479542.issue7132@psf.upfronthosting.co.za> |
2010-04-01 10:55:13 | davidchambers | link | issue7132 messages |
2010-04-01 10:55:12 | davidchambers | create | |
|