实现js的replaceAll方法
2010-09-29 14:42
211 查看
真是愁人!js居然不提供replaceAll方法,用for循环又有效率问题,给你一个正则表达式的解决方案
js 代码
String.prototype.replaceAll =
function
(s1,s2){
return
this
.replace(
new
RegExp(s1,
"gm"
),s2);
}
声明:JavaEye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
js 代码
String.prototype.replaceAll =
function
(s1,s2){
return
this
.replace(
new
RegExp(s1,
"gm"
),s2);
}
声明:JavaEye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
相关文章推荐
- js/jq替换方法replaceAll的实现
- 实现js的replaceAll方法
- 实现js的replaceAll方法
- js 实现ReplaceAll 的方法
- js 字符串的replace() 方法和实现replaceAll() 方法
- js 实现ReplaceAll 的方法(3种方式)
- js实现replaceAll方法与正则中引用变量
- js实现C#的replaceAll()的方法
- js 实现ReplaceAll 的方法
- js 实现ReplaceAll 的方法
- 实现JS中的 replaceAll 方法
- Js 实现 replaceAll 方法
- js 实现ReplaceAll 的方法
- 六十、js 实现replaceAll 方法
- 在js中,实现replaceAll的方法
- js 实现ReplaceAll 的方法
- js 实现ReplaceAll 的方法
- js 实现ReplaceAll 的方法 .
- js中实现replaceAll方法
- 实现js的replaceAll方法