js replace替換 忽略大小寫問題


實現就是控制台的內容“abc”,但是后台返回的是“ABC”,這個時候在前台遍歷,需要將后台返回的在控制台標紅。

當然控制台可以是 abc Abc等大小寫混合,以下代碼都可替換。

var flagnew = flag.replace(/[^a-z\d]/ig,"");

if(flagnew!=null){

var newstr = query.replace(new RegExp(flagnew,"ig"), "<font id='redmessage' color='red'>$&</font>");

$("#textarea").html(newstr.replace(newstr, "<font style='font-size: 14px;'>"+newstr+"</font>"));

}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM