复制代码 代码如下:
//CloseHTMLTags--------------------------------------------
functioncloseHTML(str){
vararrTags=["span","font","b","u","i","h1","h2","h3","h4","h5","h6","p","li","ul","table","div"];
for(vari=0;i
varintClose=0;
varre=newRegExp("<"+arrTags[i]+"([^<>]+|)>","ig");
vararrMatch=str.match(re);
if(arrMatch!=null)intOpen=arrMatch.length;
re=newRegExp(""+arrTags[i]+">","ig");
arrMatch=str.match(re);
if(arrMatch!=null)intClose=arrMatch.length;
for(varj=0;j
}
/*for(varj=(intOpen-intClose-1);j>=0;j--){
str+=""+arrTags[i]+">";
}*/
}
returnstr;
}
//CloseUBBTags--------------------------------------------
functioncloseUBB(str){
vararrTags=["code","quote","list","color","align","font","size","b"];
for(vari=0;i
varintClose=0;
varre=newRegExp("["+arrTags[i]+"(=[^[]]+|)]","ig");
vararrMatch=str.match(re);
if(arrMatch!=null)intOpen=arrMatch.length;
re=newRegExp("[/"+arrTags[i]+"]","ig");
arrMatch=str.match(re);
if(arrMatch!=null)intClose=arrMatch.length;
for(varj=0;j
}
}
returnstr;
}
alert(closeHTML("正常:
alert(closeHTML("有错: