I need your help to remove all characters using a Javascript Regex in string HTML Document except <body></body>
and whole string inside body tag.
I tried to use this but doesn't work:
var str = "<html><head><title></title></head><body>my content</body></html>"
str.replace(/[^\<body\>(.+)\<\\body\>]+/g,'');
I need the body content only, other option will be to use DOMParser
:
var oParser = new DOMParser(str);
var oDOM = oParser.parseFromString(str, "text/xml");
But this throws an error parsing my string document loaded via Ajax.
Thanks in advance for your suggestions!