I researched this quite a bit, but couldn\'t find a working example how to match nested html tags with attributes. I know it is possible to match balanced/neste
You can do it recursively, using the same regex but executed while needed. Like this:
function htmlToPlainText(html) {
let text = html || ''
// as there is html nested inside some html attributes, we need a recursive strategy to clean up the html
while (text !== (text = text.replace(/<[^<>]*>/g, '')));
return text
}
This works with cases like:
Lorem Ipsum
I found this script here: http://blog.stevenlevithan.com/archives/reverse-recursive-pattern