The code I have is:
matches = re.search('(<meta.*?>)', contents, re.DOTALL)
if matches:
for group in matches.groups():
metas.append(group)
title = re.search('(<title>.*?</title>)', contents, re.DOTALL)
if title.groups():
found_title = title.group(1) + '\n'
else:
found_title = ''
It's working on an HTML page that has meta and title tags (lowercase), so I would expect multiple matches for the meta tags and a nonempty title. Adding or removing parentheses around the regular expression does not seem to make a difference.