日期:2014-05-16  浏览次数:20382 次

求大神帮忙提取字符串
 "<DIV id=A5CE21F97DFB4A2DBACA963BD2D4908C@D51CD9846F21444888A21DE82F014A73 class=multi-select-item><IMG onclick=justep.MultiList.removeRow(this.parentNode.id) src/x5/$v2172a588e7d0315349fcba84be3a6b06a3bd/UI/system/images/templete/delete.gif>张三</DIV><DIV id=DB3153489BB94F9AB79EFE758568D517@D51CD9846F21444888A21DE82F014A73 class=multi-select-item><IMG onclick=justep.MultiList.removeRow(this.parentNode.id) src=/x5/$v2172a588e7d0315349fcba84be3a6b06a3bd/UI/system/images/templete/delete.gif>李四</DIV><DIV id=C9BC1EF86ECC4840B615193AFEF688EF@D51CD9846F21444888A21DE82F014A73 class=multi-select-item><IMG onclick=justep.MultiList.removeRow(this.parentNode.id) src=/x5/$v2172a588e7d0315349fcba84be3a6b06a3bd/UI/system/images/templete/delete.gif>王五</DIV>"



我想把这段html里面提取出张三、李四、王五怎么做正则怎么写?

------解决方案--------------------
var re =new RegExp("^.([u4e00-u9fa5]+).$");//试试.
 

匹配中文.[u4e00-u9fa5]
------解决方案--------------------
如果你形式是固定的也可以这样写:

var reg = new RegExp("^(<div.>\\S</div>)+$");


网吧没测试,你试试,不行给我QQ877470746
------解决方案--------------------
var aaa = "<DIV id=A5CE21F97DFB4A2DBACA963BD2D4908C@D51CD9846F21444888A21DE82F014A73 class=multi-select-item><IMG onclick=justep.MultiList.removeRow(this.parentNode.id) src/x5/$v2172a588e7d0315349fcba84be3a6b06a3bd/UI/system/images/templete/delete.gif>张三</DIV><DIV id=DB3153489BB94F9AB79EFE758568D517@D51CD9846F21444888A21DE82F014A73 class=multi-select-item><IMG onclick=justep.MultiList.removeRow(this.parentNode.id) src=/x5/$v2172a588e7d0315349fcba84be3a6b06a3bd/UI/system/images/templete/delete.gif>李四</DIV><DIV id=C9BC1EF86ECC4840B615193AFEF688EF@D51CD9846F21444888A21DE82F014A73 class=multi-select-item><IMG onclick=justep.MultiList.removeRow(this.parentNode.id) src=/x5/$v2172a588e7d0315349fcba84be3a6b06a3bd/UI/system/images/templete/delete.gif>王五</DIV>";
var reg = /[^\u4E00-\u9FA5]*([\u4E00-\u9FA5]+)[^\u4E00-\u9FA5]+/gi;
var result1 = [];
var result = aaa.replace(reg,function($1,$2){
result1.push($2);
})

for(var i =0;i<result1.length;i++){
alert(result1[i]);
}


我这个是按你给的那个是字符串写的,是不是这样?
------解决方案--------------------
试试这个,上面那个可能不行,刚没发现你的img标签

var reg = new RegExp("^(<div.><img.>\\S</div>)+$");