Why you can't parse HTML with regex
stackoverflow.com
stackoverflow.com
But, but! In StackOverflow, "regex" doesn't mean "specification for a finite state automaton which recognizes whether strings belong to a given regular language", but rather "a character matching tool implemented in whatever language or its library that a question is about".
Some so-called regex engines will match nested tags.
The question has a problem because it makes no mention of what concrete tools OP is using to solve a concrete problem.
I've spend hours trying to get something to work in BeautifulSoup that could have easily been done in minutes with regex and a few lines of python.