{"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":{"integrity":"sha512-yPpxc4ZR2makceA9hy/jHNqc7QVkd4Je/N0WRHm6bs3PtivPuPynxE5ejU/mp5EhnCv8+uZL7vhz8rkluSlx+Q==","shasum":"77a087d88580fbac59851237891aa4b0e283db72","tarball":"http://registry-npm.ywwl.com/replace-string/download/replace-string-3.1.0.tgz","fileCount":5,"unpackedSize":6231,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJet6k4CRA9TVsSAnZWagAAdVEQAIQdx6KAFeyzKXWjsFxa\n5k/tbO+9oVbGVMDkKJnZopGnvG8661u3GmOlBJn7IKvpQuYJpb1AtWsVp2bz\nbQCy59w5RF3Sw1pgHW6zvPPy/ElMRDQTAd12qIYGynKt0qmWeGjXo5JPB5lP\nCaIvMvYUOJhegBrB/lwshTJ1JLy5OuznlvwrxNmgjW7BK+s18H2yy3vyeb2f\n6mJlobWkC2FuivloPv4EQHQo4haiAyary1cL6l/D950Mzl6Y3yObauXAFiB0\nOx2E2A6UH12C2ARKC78oanOppoHSB9bhOBl8XvQCQYw1gZVtKSPTdYILv9Xi\nH37bhbbjUy8ri/lOObR8Hcz87UkycwWi4KogKJ4JqwZdDrKW5+yvqJPdv0M5\noq3nWFW8X9tcmbpso+pHOt8xkRJGFbG/dxY6fDywjSc8DMACnZ/O5QPnvmvV\nY0Hzj7AwahTwLd7hto9BBl/HbZnn3chlXSmfxrx2GtXgQR0qN1DwXcFokrRT\nYS/zOVhAqdRHd7FaObxU2sIp4ZjNVeHf1Wb6LSbYELhTfvldZxL07JdQkIqB\ncqZ/KX4ruAWEvls2XAkYA1p9GFPTfBhBOj6K0gvHKuzfaBftUR40TgGpl8F3\nCj9uDUDUccMDoQpY0mpM+/TDoBQtrzPsbHQ8VhA+VrMg88/T0CajweHdDZ4H\nGclp\r\n=k7Y4\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBoJFXyEmY7ryDQM36AVimJE0HQwqRu387P2eBsoS8IiAiEA+D/jl8b9YhaGtaNh7xB+HL+qECYsKXP4AgGDh2IRCkg="}],"size":2714,"noattachment":false,"key":"/replace-string/-/replace-string-3.1.0.tgz"},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/replace-string_3.1.0_1589094712382_0.6159361584627039"},"_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","publish_time":1589094712491,"_cnpm_publish_time":1589094712491,"dist-tags":{"latest":"4.0.0"}}