Replace all substring matches in a string
String#replace(), but supports replacing multiple matches. You could achieve something similar by putting the string in a
RegExp constructor with the global flag and passing it to
String#replace(), but you would then have to first escape the string anyways.
$ npm install --save replace-string
const replaceString = ;const input = 'My friend has a 🐑. I want a 🐑 too!';;//=> 'My friend has a 🦄. I want a 🦄 too!'
Returns a new string with all
needle matches replaced with
String to work on.
String to match in
If a function, it receives the following arguments; the
needle, the match count, and the
;//=> 'Foo 🐑❤️ Bar'
Index at which to start replacing.
RegExpmatches in a string
MIT © Sindre Sorhus