← Back to challenges

RegEx Exercise 2: Find HTML Tags

JavaScriptHardregex

Instructions

Create a regular expression to find all (opening and closing) HTML tags with their attributes. Assume that tag attributes may not contain < and > (inside quotes too).

Example

const REGEXP = /your regexp/g

let str = '<> <a href="/"> <input type="radio" checked> <b>'

str.match(REGEXP) ➞  '<a href="/">', '<input type="radio" checked>', '<b>'

Notes

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Regex Series: Canadian Postal Codes