HTML Tag Regex

Example:
<([a-z]+)([^<]+)*(?:>(.*?)<\/\1>|\s+\/>) Matches: ✓
content
Match HTML tags: <([a-z]+)([^<]+)*(?:>(.*?)<\/\1>|\s+\/>). Warning: Regex is not ideal for HTML parsing - use a proper HTML parser for production.
Try Regex Lab →

FAQs

Should I parse HTML with regex?

Not for production! Use DOMParser or libraries like cheerio. Regex cannot handle nested/malformed HTML reliably.