DEV Community

Discussion on: How to normalize (join together) bold nodes in HTML DOM?

Collapse
 
delixx profile image
DeLiXx • Edited

Simply remove any occurence of "</b><b>":

"Lorem <b>Ipsum</b><b> Dolor</b> Sit Amet".replace("</b><b>", "")

Collapse
 
jwkicklighter profile image
Jordan Kicklighter

Would be good to do this in a regex that also looks for whitespace between the two tags.

Collapse
 
delixx profile image
DeLiXx

I thought about that as well, but then you'd change the content (if only ever so slightly) for a trivial QoL improvement

Thread Thread
 
jwkicklighter profile image
Jordan Kicklighter

If you use a capture group, you could put every bit of whitepace back.