javascript 取代字串 取代所有字串 紅色死神 發表於 2013年10月2日 星期三 10月 02, 2013 / 沒有留言 標籤 javascript 最近要做一個把文字從資料庫抓出來後,把換行的 br 轉成 \n 的功能,這時要可以用 replace。 view plaincopy to clipboardprint$input_con=$input_con.replace("<br>","\n") 可是這樣只會取代第一個,要全部都取代要用正則式來處理。 view plaincopy to clipboardprintfunction ReplaceAll(strOrg,strFind,strReplace){ return strOrg.replace(new RegExp(strFind,"g"),strReplace); } 以電子郵件傳送這篇文章BlogThis!分享至 Twitter分享至 Facebook 反應:
0 意見:
張貼留言