script type="text/javascript">
function getV(){
var str=document.getElementById("regtext").value;
var re=/([\n\r])(\s)*(\\/div\&;?(\s)*\div)+/g;
str=str.replace(re,"$3");
alert(str);
}
/script>
textarea id="regtext" cols="20" rows="20">
div id="main">
div id="left">
/div>
div id="Div1">
/div>
div id="Div2">
/div>
div id="right">
脚本之家
/div>
/div>
/textarea>
input type="button" onclick="getV()" value="测试" />