Best Way to Get All HTML Tags Regex? Need Help with a Reliable Pattern!

20 Replies, 1221 Views

Regex and HTML? Oof, that’s a tough combo. I’ve tried `/<(\w+)[^>]*>(.*?)<\/\1>/g` before, and it kinda works, but it struggles with self-closing tags like `<img />`.

If you’re serious about getting all HTML tags regex, maybe look into XPath or CSS selectors instead. They’re way more robust for this kind of thing.

Messages In This Thread



Users browsing this thread: 1 Guest(s)