{"_id":"replace-string","_rev":"947593","name":"replace-string","description":"Replace all substring matches in a string","dist-tags":{"latest":"4.0.0"},"maintainers":[{"name":"sindresorhus","email":""}],"time":{"modified":"2021-09-23T02:18:36.000Z","created":"2017-01-05T13:02:19.594Z","4.0.0":"2021-08-09T20:24:04.023Z","3.1.0":"2020-05-10T07:11:52.491Z","3.0.0":"2019-04-26T06:45:03.292Z","2.0.0":"2018-10-16T09:07:34.897Z","1.1.0":"2017-01-11T07:24:20.342Z","1.0.0":"2017-01-05T13:02:19.594Z"},"users":{"felegz":true,"rocket0191":true,"codeinpixel":true},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"repository":{"type":"git","url":"git+https://github.com/sindresorhus/replace-string.git"},"versions":{"4.0.0":{"name":"replace-string","version":"4.0.0","description":"Replace all substring matches in a string","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/replace-string.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":"./index.js","engines":{"node":"^12.20.0 || ^14.13.1 || >=16.0.0"},"scripts":{"test":"xo && ava && tsd"},"keywords":["replace","string","text","all","many","multiple","global","match","matches","replacement","replacer","modify","substring","sub-string","needle","search","replaceall"],"devDependencies":{"ava":"^3.15.0","tsd":"^0.17.0","xo":"^0.44.0"},"gitHead":"b9fb6b1f143121ba93ffbcc24ee2a17f62fa7bda","bugs":{"url":"https://github.com/sindresorhus/replace-string/issues"},"homepage":"https://github.com/sindresorhus/replace-string#readme","_id":"replace-string@4.0.0","_nodeVersion":"12.22.1","_npmVersion":"7.10.0","dist":{"shasum":"2f7270b3e38d118a00ff328481305561c7fe74cf","size":2819,"noattachment":false,"key":"/replace-string/-/replace-string-4.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/replace-string/download/replace-string-4.0.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/replace-string_4.0.0_1628540643889_0.42599064551134824"},"_hasShrinkwrap":false,"publish_time":1628540644023,"_cnpm_publish_time":1628540644023},"3.1.0":{"name":"replace-string","version":"3.1.0","description":"Replace all substring matches in a string","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/replace-string.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"engines":{"node":">=8"},"scripts":{"test":"xo && ava && tsd"},"keywords":["replace","string","text","all","many","multiple","global","match","matches","replacement","replacer","modify","substring","sub-string","needle","search"],"devDependencies":{"ava":"^1.4.1","tsd":"^0.7.2","xo":"^0.24.0"},"gitHead":"9b0208efd71d8a43988db164914e0b759666ebb6","bugs":{"url":"https://github.com/sindresorhus/replace-string/issues"},"homepage":"https://github.com/sindresorhus/replace-string#readme","_id":"replace-string@3.1.0","_nodeVersion":"10.20.1","_npmVersion":"6.14.5","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"77a087d88580fbac59851237891aa4b0e283db72","size":2714,"noattachment":false,"key":"/replace-string/-/replace-string-3.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/replace-string/download/replace-string-3.1.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/replace-string_3.1.0_1589094712382_0.6159361584627039"},"_hasShrinkwrap":false,"publish_time":1589094712491,"_cnpm_publish_time":1589094712491},"3.0.0":{"name":"replace-string","version":"3.0.0","description":"Replace all substring matches in a string","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/replace-string.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=8"},"scripts":{"test":"xo && ava && tsd"},"keywords":["replace","string","text","all","many","multiple","global","match","matches","replacement","replacer","modify","substring","sub-string","needle","search"],"devDependencies":{"ava":"^1.4.1","tsd":"^0.7.2","xo":"^0.24.0"},"gitHead":"b873ad85607c736834e728bf5e452f1c926432f3","bugs":{"url":"https://github.com/sindresorhus/replace-string/issues"},"homepage":"https://github.com/sindresorhus/replace-string#readme","_id":"replace-string@3.0.0","_nodeVersion":"10.15.3","_npmVersion":"6.9.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"49deafb57839fa3bab9c11ad449b006e0d436e69","size":2522,"noattachment":false,"key":"/replace-string/-/replace-string-3.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/replace-string/download/replace-string-3.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/replace-string_3.0.0_1556261103138_0.06110468490332632"},"_hasShrinkwrap":false,"publish_time":1556261103292,"_cnpm_publish_time":1556261103292},"2.0.0":{"name":"replace-string","version":"2.0.0","description":"Replace all substring matches in a string","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/replace-string.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=6"},"scripts":{"test":"xo && ava"},"keywords":["replace","string","text","all","many","multiple","global","match","matches","replacement","replacer","modify","substring","sub-string","needle","search"],"devDependencies":{"ava":"^0.25.0","xo":"^0.23.0"},"gitHead":"4b67554beff2fde0938028cf20ead68dce87205f","bugs":{"url":"https://github.com/sindresorhus/replace-string/issues"},"homepage":"https://github.com/sindresorhus/replace-string#readme","_id":"replace-string@2.0.0","_npmVersion":"6.4.1","_nodeVersion":"10.12.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"2ba068708a4a88672e93b83acdb9f865f9e323ef","size":2239,"noattachment":false,"key":"/replace-string/-/replace-string-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/replace-string/download/replace-string-2.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/replace-string_2.0.0_1539680854758_0.9229143704817409"},"_hasShrinkwrap":false,"publish_time":1539680854897,"_cnpm_publish_time":1539680854897},"1.1.0":{"name":"replace-string","version":"1.1.0","description":"Replace all substring matches in a string","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/replace-string.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=4"},"scripts":{"test":"xo && ava"},"files":["index.js"],"keywords":["replace","string","str","text","all","many","multiple","global","match","matches","replacement","replacer","modify","substring","sub-string","needle","search"],"devDependencies":{"ava":"*","xo":"*"},"xo":{"esnext":true},"gitHead":"236a8774847d66418531a5d9c0d3940ccffb7219","bugs":{"url":"https://github.com/sindresorhus/replace-string/issues"},"homepage":"https://github.com/sindresorhus/replace-string#readme","_id":"replace-string@1.1.0","_shasum":"87062117f823fe5800c306bacb2cfa359b935fea","_from":".","_npmVersion":"2.15.11","_nodeVersion":"4.6.2","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"87062117f823fe5800c306bacb2cfa359b935fea","size":2310,"noattachment":false,"key":"/replace-string/-/replace-string-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/replace-string/download/replace-string-1.1.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/replace-string-1.1.0.tgz_1484119460096_0.7858717523049563"},"directories":{},"publish_time":1484119460342,"_cnpm_publish_time":1484119460342,"_hasShrinkwrap":false},"1.0.0":{"name":"replace-string","version":"1.0.0","description":"Replace all substring matches in a string","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/replace-string.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=4"},"scripts":{"test":"xo && ava"},"files":["index.js"],"keywords":["replace","string","str","text","all","many","multiple","global","match","matches","replacement","replacer","modify","substring","sub-string","needle","search"],"devDependencies":{"ava":"*","xo":"*"},"xo":{"esnext":true},"gitHead":"bc14d457a3cffb3a34f0a2e65544132eaf99ab77","bugs":{"url":"https://github.com/sindresorhus/replace-string/issues"},"homepage":"https://github.com/sindresorhus/replace-string#readme","_id":"replace-string@1.0.0","_shasum":"5704a780ee07efed4c0eb8168a7fb0551e2efdbf","_from":".","_npmVersion":"2.15.11","_nodeVersion":"4.6.2","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"5704a780ee07efed4c0eb8168a7fb0551e2efdbf","size":2142,"noattachment":false,"key":"/replace-string/-/replace-string-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/replace-string/download/replace-string-1.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/replace-string-1.0.0.tgz_1483621337474_0.27186012733727694"},"directories":{},"publish_time":1483621339594,"_cnpm_publish_time":1483621339594,"_hasShrinkwrap":false}},"readme":"# replace-string\n\n> Replace all substring matches in a string\n\nSimilar to `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.\n\n*With [Node.js 16](https://medium.com/@nodejs/node-js-v15-0-0-is-here-deb00750f278), this package is partly moot as there is now a [`String#replaceAll`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll) method. However, it does not have a `caseInsensitive` option.*\n\n## Install\n\n```\n$ npm install replace-string\n```\n\n## Usage\n\n```js\nimport replaceString from 'replace-string';\n\nconst string = 'My friend has a ????. I want a ???? too!';\n\nreplaceString(string, '????', '????');\n//=> 'My friend has a ????. I want a ???? too!'\n```\n\n## API\n\n### replaceString(string, needle, replacement, options?)\n\nReturns a new string with all `needle` matches replaced with `replacement`.\n\n#### string\n\nType: `string`\n\nThe string to work on.\n\n#### needle\n\nType: `string`\n\nThe string to match in `input`.\n\n#### replacement\n\nType: `string | Function`\n\nThe replacement for `needle` matches.\n\nIf a function, it receives the matched substring, the match count, the original input, and the index in which the match happened (as measured from the original input):\n\n```js\nimport replaceString from 'replace-string';\n\nreplaceString('Foo ???? Bar', '????', (matchedSubstring, matchCount, input, matchIndex) => `${matchedSubstring}❤️`);\n//=> 'Foo ????❤️ Bar'\n```\n\n#### options\n\nType: `object`\n\n##### fromIndex\n\nType: `number`\\\nDefault: `0`\n\nIndex at which to start replacing.\n\n##### caseInsensitive\n\nType: `boolean`\\\nDefault: `false`\n\nWhether or not substring matching should be case-insensitive.\n\n## Related\n\n- [execall](https://github.com/sindresorhus/execall) - Find multiple `RegExp` matches in a string\n","_attachments":{},"homepage":"https://github.com/sindresorhus/replace-string#readme","bugs":{"url":"https://github.com/sindresorhus/replace-string/issues"},"license":"MIT"}