I am acquiring the html in an html page. However I want to replace the entire contents of
<div id="fontsListing"></div>
with new contents.
I'm using the following but the regex here is messing up with my closing div tags.
How can I simply empty the contents of the fontsListing
div
and enter in req.body.savedHtml
?
Please note I can't use innerHtml as I need the actual javascript values to send to an api.
var newHtml = data.replace(/<div id="fontsListing">[\s\S]*?<\/div>/, "<div id=\"fontsListing\">" + req.body.savedHtml + "</div>");