var testa = document.getElementsByTagName('body')[0].outerHTML; var scripts = testa.replace(/<script\b[^<]*(??!<\/script>)<[^<]*)*<\/script>/gi,"")