pattern matching

monkeys paw monkey at joemoney.net
Thu Feb 24 03:11:53 CET 2011


if I have a string such as '<td>01/12/2011</td>' and i want
to reformat it as '20110112', how do i pull out the components
of the string and reformat them into a YYYYDDMM format?

I have:

import re

test = re.compile('\d\d\/')
f = open('test.html')  # This file contains the html dates
for line in f:
     if test.search(line):
         # I need to pull the date components here



More information about the Python-list mailing list