首页
视频
资源
登录
雪霏
昔我往矣,杨柳依依。今我来思,雨雪霏霏
博主信息
排名
6
文章
6
粉丝
16
评论
8
文章类别
前端
8篇
架构
1篇
随笔
6篇
EF
1篇
NET CORE
2篇
移动开发
2篇
最新文章
最新评价
{{item.articleTitle}}
{{item.blogName}}
:
{{item.content}}
关于我们
ICP备案 :
渝ICP备18016597号-1
网站信息:
2018-2025
TNBLOG.NET
技术交流:
群号656732739
联系我们:
contact@tnblog.net
公网安备:
50010702506256
欢迎加群
欢迎加群交流技术
原
js实现replaceAll
6164
人阅读
2020/7/20 17:40
总访问:
123564
评论:
0
收藏:
0
手机
分类:
随笔
使用正则即可,例如下面的替换 ``` var procContent = content.replace(new RegExp("<br/>", "gm"), "<br>"); ``` 也可以使用一个扩展方法 ``` String.prototype.replaceAll = function(before, new) { return this.replace(new RegExp(before, "gm"), new); } ``` 使用 ``` var str = "dogdogdog"; var str2 = str.replaceAll("dog", "cat"); console.log(str2); ```
👈{{preArticle.title}}
👉{{nextArticle.title}}
评价
{{titleitem}}
{{titleitem}}
{{item.content}}
{{titleitem}}
{{titleitem}}
{{item.content}}