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

20 Replies, 1537 Views

Regex for HTML is a rabbit hole, man. I’ve used `/<(\w+)[^>]*>(.*?)<\/\1>/g`, and it’s okay for basic tags, but it falls apart with nested stuff.

For self-closing tags, you might need to add something like `/<[^>]+\/>/g` to catch those. But honestly, just use an HTML parser. It’ll save you so much headache.

Messages In This Thread



Users browsing this thread: 1 Guest(s)