{"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":{"integrity":"sha512-fcgyZ62o26oBaihEC302pZQ2WectvmZ4sGOq4Lwa8ad12lPbhIlZCvLpgpI1sOAsbN83kpXiH5KCcr3pcZa8bA==","shasum":"2f7270b3e38d118a00ff328481305561c7fe74cf","tarball":"http://registry-npm.ywwl.com/replace-string/download/replace-string-4.0.0.tgz","fileCount":5,"unpackedSize":6518,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhEY7kCRA9TVsSAnZWagAAxAQP/3yeQY8hWPi4HB0PXWP8\nqF56VJlOTbWfSoIFrgSLUEdFBSVPNcoEBKM+q6mg4C1iDwSjcVcea1XwIrt3\n9w/+llW7tS0eMPyCidWefTGbl1g+YjNigQ9YclIuRA8zXAvg+h6MVxoNomYL\n3MhbgWaHlFB9ZuoNAY61LZaoyIHL724it2sRXz0cN2xk/bj6WTZbODAGievg\n0z2oze3wmNG8fLr3juMXVCpH9RM9QGzoBFa/44qd8dRuU3MTXO4WRP6d9fHh\nQcyWsqsasRNMR6qpVo3eHwKo4jPm9qhwNtE+DNUwzU3/OmD1DAjxXjFxVUrk\nLapV3rofcWBK6dQu8ch4ksfTJdMZ50tOlKvsOclPKhMJqPm8tlbmJByXtSgE\nVCVReERsBoNJys1VKQKbycUb2R6XJ0+Xc1zIFd73fuPkammzE98V/uRE8sab\npxLwXNhvGm3R77XHQOixjBiwbwA/h6euQ8SlH6l7Mfrdl1X9cM7U0A2F8Xik\nGpOrqR2V/lsOgZco0YDXkNOj8Kiym+CbmcqQXpprC2am/LqE0xU5W1ELFQhB\n5Jx200WYkOs8IllUZVlRmon+RVXfCKbMSqp6js9r+GUKOWIg4E/tdwmWXVSL\nIf97cd7AQDBq3+voaofGdG976NSVJQZWsEiyVye1S0XXRbkzlhDnUgi4CTeJ\n2WKD\r\n=dc7C\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBrHhgAOi/lMIGo7zstcDUSJokEANf2nlQOlhj1BEDulAiEAi6gof+XGjK3i8dvCCaIPoE5O8gtV389B9x+ODuX3XPY="}],"size":2819,"noattachment":false,"key":"/replace-string/-/replace-string-4.0.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/replace-string_4.0.0_1628540643889_0.42599064551134824"},"_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":1628540644023,"_cnpm_publish_time":1628540644023,"dist-tags":{"latest":"4.0.0"}}