日期:2014-05-16 浏览次数:21127 次
<script language="javascript" runat="server">
function getDataId(str)
{
var v="",str2="";
var v1;
v1=str.match(/data_id="\w+"/gi);
if(v1!="")
{
var v2=new Array();
v2=(v1+'').split(',');
var current="";
for(i=0;i<v2.length;i++)
{
current=v2[i].toString();
str2+=current+"<hr>";
}
}
return str2;
}
</script>
<%
str="<div id=""body"" class=""dragZone""><div class=""main""><div class=""wrap""><div class=""dragWrap""><div class=""slide drag"" id=""slide"" data_id=""pic"" data_tit=""幻灯片1""><div class=""box""><ul class=""list"">11111111</ul></div></div></div><div class=""box_01 mt-20 cf""><div class=""ann_wrap dragWrap""><dl class=""ann bd_01 drag"" Data_ID=""pic3"" data_tit=""幻灯片2""><dt>{$notice_title}</dt><dd id=""ad""><ul><li i=""{notice1.i}"">333333</li></ul></dd></dl></div></div></div></div></div>"
response.write getDataId(str)
%>
function getDataId(str) {
var str2 = "";
var v1 = str.match(/<([a-z]+) [^>]+?data_id[\s\S]+?<\/\1>/gi);
if (v1) {
var current = "";
for (i = 0; i < v1.length; i++) {
current = v1[i].toString();
if (current.indexOf('<div') == 0) current += '</div>';//按照你原来的结构不全div,如果有多组嵌套的,上面的正则也无法使用
str2 += current + "<hr>";
}
}
return str2;
}