<p><span><a href="RelpyList.aspx?rid=70864" target="_blank">RelpyList1314:</a></span> This RelpyList is 嘿嘿</p>如上一段HTML代码,我想将“This RelpyList is 嘿嘿”中的 "RelpyList"字符 替换成 "RL"字符,但是a标签中"RelpyList.aspx"与“RelpyList1314”这两字符不要替换。该如何写呢?
调试欢乐多
var str='<p><span><a href="RelpyList.aspx?rid=70864" target="_blank">RelpyList1314:</a></span> This RelpyList is 嘿嘿</p>'
alert(str.replace(/\sRelpyList\s/g," RL "))
var reg = /This\s*(RelpyList){1}/g;alert( s.replace(reg, function( $0, $1 ) {
return $0.replace( $1, "RL");
}));
var reg = /This\s*(RelpyList)/g;alert( s.replace(reg, function( $0, $1 ) {
return $0.replace( $1, "RL");
}));
var te=c.replace(re,function($0,$1){
var r =new RegExp("RelpyList", "ig")
return $1.replace(r,'<a href="SearchResult.aspx?kw=' + encodeURIComponent(kv) + '" target="_blank">'+kv+'</a>') })
return $0.replace( $1, no);
})