I need to remove the entire content of style tags from an html string, in multiple occurrences. I can't use a DOM parser for it.
How could i do this, in JavaScript?
For those that land here in 2020 this worked for me.
string.replace(/(<style[\w\W]+style>)/g, "")
As Bergi alluded to in the OP comments thought, this should be regarded as a last resort if there are no better options. RegEx is not the best way to deal with HTML.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With