You probably should not be using regex to parse HTML. Instead, consider using the Beautiful Soup library:
from bs4 import BeautifulSoup soup = BeautifulSoup(html_doc, 'html.parser') for img in soup.find_all('img'): print(img.get('alt'))
Soup is primarily an HTML parser, and will crawl over your nested HTML text in a safe way. Regex would only be appropriate here if you had a larger text with some HTML tags strewn throughout it.
CLICK HERE to find out more related problems solutions.