import re

f = open("calendar.html")
data = f.read()
f.close()

tableMatch = re.search(
	"instruction and finals.*?<table.*?>"		# prefix
	"(?P<body>.*?)"					# body
	"</table>",					# suffix
	data,
	re.DOTALL)
body = tableMatch.group("body")
#print body
rows = re.findall(
	"<tr.*?>(.*?)</tr>",
	body,
	re.DOTALL | re.MULTILINE)
#print rows
fieldPattern = re.compile("<td.*?>(.*?)</td>", re.DOTALL | re.MULTILINE)
for row in rows:
	fields = fieldPattern.findall(row)
	if len(fields) == 3:
		date = re.sub("\s+", " ", re.sub("<.*?>", "", fields[1]))
		name = re.sub("\s+", " ", re.sub("<.*?>", "", fields[0]))
		print date, name
