I’ve got a number of calculations that return HTML for use in forms. There are also some times when I want to build a larger html content block for a report or such that utilizes these calculations. Rather than repeat myself and re-code the calc, I wrote a little helper method that uses regex to lop off any wrapping html/body tags from the calc result, so I can nest it inside a larger html document.
Just thought someone else might find it useful:
var s = arguments[0];
s = s.replace(/<html[^>]*>(.|\s)*<body[^>]*>/i, '');
s = s.replace(/<\/body>(.|\s)*<\/html>.*/i, '');
return s;
Let me know if anyone notices any flaws in my regex, but I think it should handle just about any combination of tags/attributes.
greg.