← Back to all regex patterns
Extraction
Low backtracking risk

Regex to Extract HTML Tags

Useful when you need quick tag-level extraction for diagnostics, not full HTML parsing. It matches opening and closing tags with their attributes.

Regex
/<\/?[A-Za-z][^>]*>/g

Try this pattern

Matches current input
<div class="note">

1 match found in the current text.

Passing examples

  • <div class="note">
  • </section>

Failing examples

  • plain text only
  • 2 < 5

Code examples

JavaScript
const regex = /<\/?[A-Za-z][^>]*>/g;
regex.test(input);
Python
import re
pattern = re.compile(r"<\/?[A-Za-z][^>]*>")
bool(pattern.search(input))
Go
re := regexp.MustCompile("<\\/?[A-Za-z][^>]*>")
matched := re.MatchString(input)

Related Extraction Patterns