const str = '<div class="beautiful">,<p class="provocative">,<h1 class="attractive" id="header">,<span class="sexy">,' + '</span>,</h1>,</p>,</div>'; const reg = /<(/?)(?!p|/p|div|/div)([w]+(?=>|s))/g; console.log(str.replace(reg, '<$1p'));
const str = '<div class="beautiful">,<p class="provocative">,<h1 class="attractive" id="header">,<span class="sexy">,' + '</span>,</h1>,</p>,</div>'; const reg = /<(/?)(?!p|/p|div|/div)([w]+(?=>|s))/g; console.log(str.replace(reg, '<$1p'));