var str = "something<div id='testid' class='test'><p>This is the body</p></div><div>some other div</div><div id='testid' class='test'><p>This is the body</p></div>hahahah";
var re = /(.*?)(\<div\s+.*?id\s*\=.*?\>)(.*?)(\<\/div\>)(.*?)/gi;
var newstr = str.replace( re, "$1$3$5" );
alert( newstr );