---
title: "JS replace"
author: "java.zhangshuling"
date: "2018-11-08T16:12:14Z"
tags: []
categories: ["Web前端"]
slug: "js-replace"
draft: false
lastmod: "2018-11-08T16:12:14Z"
id: 2433505
url: "https://java-zhangshuling.iteye.com/blog/2433505"
---

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

```