I'm cleaning the output created by a wysiwyg, where instead of inserting a break it simply creates an empty p tag, but it sometimes creates other empty tags that's not needed.
I have a regex to remove all empty tags, but I want to exclude empty p tags from it. how do I do that?
let s = "<h1>test</h1><h1></h1><p>a</p><p></p><h2></h2>";
s = s.trim().replace( /<(\w*)\s*[^\/>]*>\s*<\/\1>/g, '' )
console.log(s)