正则表达式问题
function clearHTML(html){
var strInput=html;
var regExp=/ <span style= "background:#DC143C "> | </span> /ig;
var strOutput=strInput.replace(regExp, " ");
return strOutput;
}
我这个正则哪里错了啊,怎么老是说没有对象呢?
------解决方案--------------------function clearHTML(html){
var strInput=html;
var regExp=/( <span style=\ "background:#DC143C\ "> | <\/span> )/ig;
var strOutput=strInput.replace(regExp, " ");
alert(strOutput)
return strOutput;
}
clearHTML( ' <span style= "background:#DC143C "> 123231 </span> ')
------解决方案--------------------function clearHTML(html){
var strInput=html;
var regExp=/ <span style= "background:\s*#DC143C "> \| <\/span> /ig;
var strOutput=strInput.replace(regExp, " ");
return strOutput;
}