{"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","tarball":"http://registry-npm.ywwl.com/replace-string/download/replace-string-1.0.0.tgz","integrity":"sha512-KuXnoXuUnNHyVEeZS0WdpwP9AOVDunf4zvXKD19iHo796KMjzODTFqL96TSjsEMNrBJulgbw8vE591L0T7BRhA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC2X2egE9WcTeNo23VBXWWBhCc0y//M6MjIwPluHtrlbQIhAKRNnxdrMYye+VeqDflW4Gu007/vi9b0hXs3mCfZfn9K"}],"size":2142,"noattachment":false,"key":"/replace-string/-/replace-string-1.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/replace-string-1.0.0.tgz_1483621337474_0.27186012733727694"},"directories":{},"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","publish_time":1483621339594,"_cnpm_publish_time":1483621339594,"dist-tags":{"latest":"4.0.0"}}