pattern matching

monkeys paw monkey at joemoney.net
Wed Feb 23 21:11:53 EST 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