首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

js的replaceall步骤

2012-08-31 
js的replaceall方法js中只包括replace方法不提供replaceAll方法 用for循环又有效率问题,用一个正则表达式

js的replaceall方法
js中只包括replace方法不提供replaceAll方法 用for循环又有效率问题,用一个正则表达式的解决方案(gm  g=global, m=multiLine)

String.prototype.replaceAll  = function(s1,s2){
return this.replace(new RegExp(s1,"gm"),s2);
}

之后就可以使用replaceAll方法了
  src.replaceAll("<br>","\r\n")

热点排行
Bad Request.