A Regular Expression to match opening and closing HTML tags with attributes.
/<\/?(\w+)(\s+\w+=(\w+|"[^"]*"|'[^']*'))*>/
Matches:
- <a>
- </p>
- <h1 class=”demo”>
Non-matches:
- ABC
- <a
- <h1 class=”demo”></h1>
See Also:
Rate This Regex
User Review
( votes)Expression Flags
Flags | Description |
---|---|
i |
Ignore case sensitive. |
g |
Allows global search. |
m |
Allows multiline search. |