function heightlight(string, keyword) {//如何实现??? var reg = new RegExp(keyword, "gi");//string = string.replace(reg, "<span class='heightlight'>$1</span>");string = string.replace(reg, "<span class='heightlight'>"+keyword+"</span>");return string;}//比如var str="aaABbac";var result=heightlight(str,"AabB");//如何才能实现返回以下的结果://"a<span class='heightlight'>aABb</span>ac"//如果string = string.replace(reg, "<span class='heightlight'>$1</span>")能实现那就方便多了,但replace()方法的字符$1这样用好像不行,求教各位大神指点!!!!!!
添加回答
举报
0/150
提交
取消