import re

print [n.group(1) for n in re.finditer('(([a-z]+)\.(txt|html))', 'abc.txt def.html')]
