The re.DOTALL flag tells python to make the ‘.’ special character match all characters, including newline characters.
import re paragraph = \ ''' This is a paragraph. It has multiple lines. ''' match = re.search(r'<p>.*</p>', paragraph, re.DOTALL) print match.group(0)
This is a paragraph. It has multiple lines.