{"_id":"@stdlib/string-base-replace","_rev":"4679322","name":"@stdlib/string-base-replace","description":"Replace search occurrences with a replacement string.","dist-tags":{"latest":"0.2.3"},"maintainers":[{"name":"kgryte","email":"kgryte@gmail.com"},{"name":"planeshifter","email":"pgb@andrew.cmu.edu"},{"name":"rreusser","email":"rsreusser@gmail.com"},{"name":"stdlib-bot","email":""}],"time":{"modified":"2026-04-11T00:30:20.000Z","created":"2022-09-17T19:58:34.351Z","0.2.3":"2026-02-01T05:12:11.604Z","0.2.2":"2024-07-26T13:51:30.218Z","0.2.1":"2024-02-21T15:12:20.767Z","0.2.0":"2024-02-14T03:21:22.108Z","0.1.1":"2023-10-03T22:42:31.946Z","0.1.0":"2023-09-22T02:59:45.364Z","0.0.2":"2022-09-17T20:38:46.080Z","0.0.1":"2022-09-17T19:58:34.351Z"},"users":{},"author":{"name":"The Stdlib Authors","url":"https://github.com/stdlib-js/stdlib/graphs/contributors"},"repository":{"type":"git","url":"git://github.com/stdlib-js/string-base-replace.git"},"versions":{"0.2.3":{"name":"@stdlib/string-base-replace","version":"0.2.3","description":"Replace search occurrences with a replacement string.","license":"Apache-2.0","author":{"name":"The Stdlib Authors","url":"https://github.com/stdlib-js/stdlib/graphs/contributors"},"contributors":[{"name":"The Stdlib Authors","url":"https://github.com/stdlib-js/stdlib/graphs/contributors"}],"main":"./lib","directories":{"doc":"./docs","lib":"./lib","dist":"./dist"},"types":"./docs/types","scripts":{},"homepage":"https://stdlib.io","repository":{"type":"git","url":"git://github.com/stdlib-js/string-base-replace.git"},"bugs":{"url":"https://github.com/stdlib-js/stdlib/issues"},"dependencies":{},"devDependencies":{},"engines":{"node":">=0.10.0","npm":">2.7.0"},"os":["aix","darwin","freebsd","linux","macos","openbsd","sunos","win32","windows"],"keywords":["stdlib","stdstring","utilities","utility","utils","util","base","string","str","search","replace","regex","regular expression","regexp","regular","expression"],"funding":{"type":"opencollective","url":"https://opencollective.com/stdlib"},"_id":"@stdlib/string-base-replace@0.2.3","gitHead":"ee4e852c6aebea0c9ce7316f364736622e4bf6a4","_nodeVersion":"20.20.0","_npmVersion":"10.8.2","dist":{"shasum":"2e3588f47dba7537c884424854ebc5b49785d71c","size":7887,"noattachment":false,"key":"/@stdlib/string-base-replace/-/@stdlib/string-base-replace-0.2.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/@stdlib/string-base-replace/download/@stdlib/string-base-replace-0.2.3.tgz"},"_npmUser":{"name":"stdlib-bot","email":"kgryte+stdlibbot@gmail.com"},"maintainers":[{"name":"kgryte","email":"kgryte@gmail.com"},{"name":"planeshifter","email":"pgb@andrew.cmu.edu"},{"name":"rreusser","email":"rsreusser@gmail.com"},{"name":"stdlib-bot","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/string-base-replace_0.2.3_1769922731470_0.9535203087538149"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2026-02-01T05:12:11.604Z","publish_time":1769922731604,"_source_registry_name":"default","_cnpm_publish_time":1769922731604},"0.2.2":{"name":"@stdlib/string-base-replace","version":"0.2.2","description":"Replace search occurrences with a replacement string.","license":"Apache-2.0","author":{"name":"The Stdlib Authors","url":"https://github.com/stdlib-js/stdlib/graphs/contributors"},"contributors":[{"name":"The Stdlib Authors","url":"https://github.com/stdlib-js/stdlib/graphs/contributors"}],"main":"./lib","directories":{"doc":"./docs","lib":"./lib","dist":"./dist"},"types":"./docs/types","scripts":{},"homepage":"https://stdlib.io","repository":{"type":"git","url":"git://github.com/stdlib-js/string-base-replace.git"},"bugs":{"url":"https://github.com/stdlib-js/stdlib/issues"},"dependencies":{},"devDependencies":{},"engines":{"node":">=0.10.0","npm":">2.7.0"},"os":["aix","darwin","freebsd","linux","macos","openbsd","sunos","win32","windows"],"keywords":["stdlib","stdstring","utilities","utility","utils","util","base","string","str","search","replace","regex","regular expression","regexp","regular","expression"],"funding":{"type":"opencollective","url":"https://opencollective.com/stdlib"},"gitHead":"2c377ebcdbfa36606bbe69e25c309e12a7965a24","_id":"@stdlib/string-base-replace@0.2.2","_nodeVersion":"16.20.2","_npmVersion":"8.19.4","dist":{"shasum":"d5f8967600d530b2b2938ba1a8c1b333b6be8c1f","size":7704,"noattachment":false,"key":"/@stdlib/string-base-replace/-/@stdlib/string-base-replace-0.2.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/@stdlib/string-base-replace/download/@stdlib/string-base-replace-0.2.2.tgz"},"_npmUser":{"name":"stdlib-bot","email":"kgryte+stdlibbot@gmail.com"},"maintainers":[{"name":"kgryte","email":"kgryte@gmail.com"},{"name":"planeshifter","email":"pgb@andrew.cmu.edu"},{"name":"rreusser","email":"rsreusser@gmail.com"},{"name":"stdlib-bot","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/string-base-replace_0.2.2_1722001890076_0.803686026259758"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-07-26T13:51:30.218Z","publish_time":1722001890218,"_source_registry_name":"default","_cnpm_publish_time":1722001890218},"0.2.1":{"name":"@stdlib/string-base-replace","version":"0.2.1","description":"Replace search occurrences with a replacement string.","license":"Apache-2.0","author":{"name":"The Stdlib Authors","url":"https://github.com/stdlib-js/stdlib/graphs/contributors"},"contributors":[{"name":"The Stdlib Authors","url":"https://github.com/stdlib-js/stdlib/graphs/contributors"}],"main":"./lib","directories":{"doc":"./docs","lib":"./lib","dist":"./dist"},"types":"./docs/types","scripts":{},"homepage":"https://stdlib.io","repository":{"type":"git","url":"git://github.com/stdlib-js/string-base-replace.git"},"bugs":{"url":"https://github.com/stdlib-js/stdlib/issues"},"dependencies":{},"devDependencies":{},"engines":{"node":">=0.10.0","npm":">2.7.0"},"os":["aix","darwin","freebsd","linux","macos","openbsd","sunos","win32","windows"],"keywords":["stdlib","stdstring","utilities","utility","utils","util","base","string","str","search","replace","regex","regular expression","regexp","regular","expression"],"funding":{"type":"opencollective","url":"https://opencollective.com/stdlib"},"gitHead":"64931c5fdb4abc3a339b619658d3b5acc089e556","_id":"@stdlib/string-base-replace@0.2.1","_nodeVersion":"16.20.2","_npmVersion":"8.19.4","dist":{"shasum":"38b0e7357991cdbc0ad93d59900d37ed144ee6c3","size":7703,"noattachment":false,"key":"/@stdlib/string-base-replace/-/@stdlib/string-base-replace-0.2.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/@stdlib/string-base-replace/download/@stdlib/string-base-replace-0.2.1.tgz"},"_npmUser":{"name":"stdlib-bot","email":"kgryte+stdlibbot@gmail.com"},"maintainers":[{"name":"kgryte","email":"kgryte@gmail.com"},{"name":"planeshifter","email":"pgb@andrew.cmu.edu"},{"name":"rreusser","email":"rsreusser@gmail.com"},{"name":"stdlib-bot","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/string-base-replace_0.2.1_1708528340562_0.3540379458765732"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-02-21T15:12:20.767Z","publish_time":1708528340767,"_source_registry_name":"default","_cnpm_publish_time":1708528340767},"0.2.0":{"name":"@stdlib/string-base-replace","version":"0.2.0","description":"Replace search occurrences with a replacement string.","license":"Apache-2.0","author":{"name":"The Stdlib Authors","url":"https://github.com/stdlib-js/stdlib/graphs/contributors"},"contributors":[{"name":"The Stdlib Authors","url":"https://github.com/stdlib-js/stdlib/graphs/contributors"}],"main":"./lib","directories":{"benchmark":"./benchmark","doc":"./docs","example":"./examples","lib":"./lib","test":"./test"},"types":"./docs/types","scripts":{"test":"make test","test-cov":"make test-cov","examples":"make examples","benchmark":"make benchmark"},"homepage":"https://stdlib.io","repository":{"type":"git","url":"git://github.com/stdlib-js/string-base-replace.git"},"bugs":{"url":"https://github.com/stdlib-js/stdlib/issues"},"dependencies":{},"devDependencies":{"@stdlib/assert-is-string":"^0.1.1","@stdlib/string-base-capitalize":"^0.1.1","tape":"git+https://github.com/kgryte/tape.git#fix/globby","istanbul":"^0.4.1","tap-min":"git+https://github.com/Planeshifter/tap-min.git","@stdlib/bench-harness":"^0.1.2","@stdlib/bench":"^0.3.1"},"engines":{"node":">=0.10.0","npm":">2.7.0"},"os":["aix","darwin","freebsd","linux","macos","openbsd","sunos","win32","windows"],"keywords":["stdlib","stdstring","utilities","utility","utils","util","base","string","str","search","replace","regex","regular expression","regexp","regular","expression"],"funding":{"type":"opencollective","url":"https://opencollective.com/stdlib"},"gitHead":"7137673f0798ef13d7c9fd7becf78e557b1d583b","_id":"@stdlib/string-base-replace@0.2.0","_nodeVersion":"16.20.2","_npmVersion":"8.19.4","dist":{"shasum":"530bf60d9d8adcc5e290a5d43fed5207053d949e","size":7864,"noattachment":false,"key":"/@stdlib/string-base-replace/-/@stdlib/string-base-replace-0.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@stdlib/string-base-replace/download/@stdlib/string-base-replace-0.2.0.tgz"},"_npmUser":{"name":"stdlib-bot","email":"kgryte+stdlibbot@gmail.com"},"maintainers":[{"name":"kgryte","email":"kgryte@gmail.com"},{"name":"planeshifter","email":"pgb@andrew.cmu.edu"},{"name":"rreusser","email":"rsreusser@gmail.com"},{"name":"stdlib-bot","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/string-base-replace_0.2.0_1707880881962_0.6395256785444914"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-02-14T03:21:22.108Z","publish_time":1707880882108,"_source_registry_name":"default","_cnpm_publish_time":1707880882108},"0.1.1":{"name":"@stdlib/string-base-replace","version":"0.1.1","description":"Replace search occurrences with a replacement string.","license":"Apache-2.0","author":{"name":"The Stdlib Authors","url":"https://github.com/stdlib-js/stdlib/graphs/contributors"},"contributors":[{"name":"The Stdlib Authors","url":"https://github.com/stdlib-js/stdlib/graphs/contributors"}],"main":"./lib","directories":{"benchmark":"./benchmark","doc":"./docs","example":"./examples","lib":"./lib","test":"./test"},"types":"./docs/types","scripts":{"test":"make test","test-cov":"make test-cov","examples":"make examples","benchmark":"make benchmark"},"homepage":"https://stdlib.io","repository":{"type":"git","url":"git://github.com/stdlib-js/string-base-replace.git"},"bugs":{"url":"https://github.com/stdlib-js/stdlib/issues"},"dependencies":{},"devDependencies":{"@stdlib/assert-is-string":"^0.1.0","@stdlib/bench":"^0.1.0","@stdlib/string-base-capitalize":"^0.1.0","tape":"git+https://github.com/kgryte/tape.git#fix/globby","istanbul":"^0.4.1","tap-min":"git+https://github.com/Planeshifter/tap-min.git"},"engines":{"node":">=0.10.0","npm":">2.7.0"},"os":["aix","darwin","freebsd","linux","macos","openbsd","sunos","win32","windows"],"keywords":["stdlib","stdstring","utilities","utility","utils","util","base","string","str","search","replace","regex","regular expression","regexp","regular","expression"],"funding":{"type":"opencollective","url":"https://opencollective.com/stdlib"},"gitHead":"836b37cf688bfa381fcb3cb3a2dd327f0a94ad19","_id":"@stdlib/string-base-replace@0.1.1","_nodeVersion":"16.20.2","_npmVersion":"8.19.4","dist":{"shasum":"a0b0dfc9a81499fc6fa04cdc4ab5985af83895ee","size":7996,"noattachment":false,"key":"/@stdlib/string-base-replace/-/@stdlib/string-base-replace-0.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/@stdlib/string-base-replace/download/@stdlib/string-base-replace-0.1.1.tgz"},"_npmUser":{"name":"stdlib-bot","email":"kgryte+stdlibbot@gmail.com"},"maintainers":[{"name":"kgryte","email":"kgryte@gmail.com"},{"name":"planeshifter","email":"pgb@andrew.cmu.edu"},{"name":"rreusser","email":"rsreusser@gmail.com"},{"name":"stdlib-bot","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/string-base-replace_0.1.1_1696372951665_0.18693203819280257"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-10-03T22:42:31.946Z","publish_time":1696372951946,"_source_registry_name":"default","_cnpm_publish_time":1696372951946},"0.1.0":{"name":"@stdlib/string-base-replace","version":"0.1.0","description":"Replace search occurrences with a replacement string.","license":"Apache-2.0","author":{"name":"The Stdlib Authors","url":"https://github.com/stdlib-js/stdlib/graphs/contributors"},"contributors":[{"name":"The Stdlib Authors","url":"https://github.com/stdlib-js/stdlib/graphs/contributors"}],"main":"./lib","directories":{"benchmark":"./benchmark","doc":"./docs","example":"./examples","lib":"./lib","test":"./test"},"types":"./docs/types","scripts":{"test":"make test","test-cov":"make test-cov","examples":"make examples","benchmark":"make benchmark"},"homepage":"https://stdlib.io","repository":{"type":"git","url":"git://github.com/stdlib-js/string-base-replace.git"},"bugs":{"url":"https://github.com/stdlib-js/stdlib/issues"},"dependencies":{},"devDependencies":{"@stdlib/assert-is-string":"^0.0.8","@stdlib/bench":"^0.0.12","@stdlib/string-base-capitalize":"^0.0.2","tape":"git+https://github.com/kgryte/tape.git#fix/globby","istanbul":"^0.4.1","tap-min":"git+https://github.com/Planeshifter/tap-min.git"},"engines":{"node":">=0.10.0","npm":">2.7.0"},"os":["aix","darwin","freebsd","linux","macos","openbsd","sunos","win32","windows"],"keywords":["stdlib","stdstring","utilities","utility","utils","util","base","string","str","search","replace","regex","regular expression","regexp","regular","expression"],"funding":{"type":"opencollective","url":"https://opencollective.com/stdlib"},"gitHead":"4f2310de3494fe36f4b74db309593f63e9d24dcc","_id":"@stdlib/string-base-replace@0.1.0","_nodeVersion":"16.20.2","_npmVersion":"8.19.4","dist":{"shasum":"f77c20d8f32964165fe5c2808b10d6f67c2f6d27","size":8003,"noattachment":false,"key":"/@stdlib/string-base-replace/-/@stdlib/string-base-replace-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@stdlib/string-base-replace/download/@stdlib/string-base-replace-0.1.0.tgz"},"_npmUser":{"name":"stdlib-bot","email":"kgryte+stdlibbot@gmail.com"},"maintainers":[{"name":"kgryte","email":"kgryte@gmail.com"},{"name":"planeshifter","email":"pgb@andrew.cmu.edu"},{"name":"rreusser","email":"rsreusser@gmail.com"},{"name":"stdlib-bot","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/string-base-replace_0.1.0_1695351585157_0.76498765238979"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-09-22T02:59:45.364Z","publish_time":1695351585364,"_source_registry_name":"default","_cnpm_publish_time":1695351585364},"0.0.2":{"name":"@stdlib/string-base-replace","version":"0.0.2","description":"Replace search occurrences with a replacement string.","license":"Apache-2.0","author":{"name":"The Stdlib Authors","url":"https://github.com/stdlib-js/stdlib/graphs/contributors"},"contributors":[{"name":"The Stdlib Authors","url":"https://github.com/stdlib-js/stdlib/graphs/contributors"}],"main":"./lib","directories":{"benchmark":"./benchmark","doc":"./docs","example":"./examples","lib":"./lib","test":"./test"},"types":"./docs/types","scripts":{"test":"make test","test-cov":"make test-cov","examples":"make examples","benchmark":"make benchmark"},"homepage":"https://stdlib.io","repository":{"type":"git","url":"git://github.com/stdlib-js/string-base-replace.git"},"bugs":{"url":"https://github.com/stdlib-js/stdlib/issues"},"dependencies":{},"devDependencies":{"@stdlib/assert-is-string":"^0.0.x","@stdlib/bench":"^0.0.x","@stdlib/string-base-capitalize":"^0.0.x","tape":"git+https://github.com/kgryte/tape.git#fix/globby","istanbul":"^0.4.1","tap-spec":"5.x.x"},"engines":{"node":">=0.10.0","npm":">2.7.0"},"os":["aix","darwin","freebsd","linux","macos","openbsd","sunos","win32","windows"],"keywords":["stdlib","stdstring","utilities","utility","utils","util","base","string","str","search","replace","regex","regular expression","regexp","regular","expression"],"funding":{"type":"patreon","url":"https://www.patreon.com/athan"},"gitHead":"d616052487f36787a86b0d2d1fcec4a45cfeead5","_id":"@stdlib/string-base-replace@0.0.2","_nodeVersion":"16.17.0","_npmVersion":"8.15.0","dist":{"shasum":"f6f57a274eed919fb9e9f2a190ac2ebebdf4901b","size":7087,"noattachment":false,"key":"/@stdlib/string-base-replace/-/@stdlib/string-base-replace-0.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/@stdlib/string-base-replace/download/@stdlib/string-base-replace-0.0.2.tgz"},"_npmUser":{"name":"kgryte","email":"kgryte@gmail.com"},"maintainers":[{"name":"kgryte","email":"kgryte@gmail.com"},{"name":"planeshifter","email":"pgb@andrew.cmu.edu"},{"name":"rreusser","email":"rsreusser@gmail.com"},{"name":"stdlib-bot","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/string-base-replace_0.0.2_1663447125924_0.6507625051424577"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-09-17T20:38:55.482Z","publish_time":1663447126080,"_cnpm_publish_time":1663447126080},"0.0.1":{"name":"@stdlib/string-base-replace","version":"0.0.1","description":"Replace search occurrences with a replacement string.","license":"Apache-2.0","author":{"name":"The Stdlib Authors","url":"https://github.com/stdlib-js/stdlib/graphs/contributors"},"contributors":[{"name":"The Stdlib Authors","url":"https://github.com/stdlib-js/stdlib/graphs/contributors"}],"main":"./lib","directories":{"benchmark":"./benchmark","doc":"./docs","example":"./examples","lib":"./lib","test":"./test"},"types":"./docs/types","scripts":{"test":"make test","test-cov":"make test-cov","examples":"make examples","benchmark":"make benchmark"},"homepage":"https://stdlib.io","repository":{"type":"git","url":"git://github.com/stdlib-js/string-base-replace.git"},"bugs":{"url":"https://github.com/stdlib-js/stdlib/issues"},"dependencies":{},"devDependencies":{"@stdlib/assert-is-string":"^0.0.x","@stdlib/bench":"^0.0.x","@stdlib/string-base-capitalize":"^0.0.x","tape":"git+https://github.com/kgryte/tape.git#fix/globby","istanbul":"^0.4.1","tap-spec":"5.x.x"},"engines":{"node":">=0.10.0","npm":">2.7.0"},"os":["aix","darwin","freebsd","linux","macos","openbsd","sunos","win32","windows"],"keywords":["stdlib","stdstring","utilities","utility","utils","util","base","string","str","search","replace","regex","regular expression","regexp","regular","expression"],"funding":{"type":"patreon","url":"https://www.patreon.com/athan"},"gitHead":"6e20e02a88699bed4a40ee348362a2b24d17ebd8","_id":"@stdlib/string-base-replace@0.0.1","_nodeVersion":"16.17.0","_npmVersion":"8.15.0","dist":{"shasum":"797edfa71828114fccc5e951fab763fd37c17b3b","size":7086,"noattachment":false,"key":"/@stdlib/string-base-replace/-/@stdlib/string-base-replace-0.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/@stdlib/string-base-replace/download/@stdlib/string-base-replace-0.0.1.tgz"},"_npmUser":{"name":"kgryte","email":"kgryte@gmail.com"},"maintainers":[{"name":"kgryte","email":"kgryte@gmail.com"},{"name":"planeshifter","email":"pgb@andrew.cmu.edu"},{"name":"rreusser","email":"rsreusser@gmail.com"},{"name":"stdlib-bot","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/string-base-replace_0.0.1_1663444714156_0.7330582749554317"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-09-17T19:59:11.687Z","publish_time":1663444714351,"_cnpm_publish_time":1663444714351}},"readme":"<!--\n\n@license Apache-2.0\n\nCopyright (c) 2022 The Stdlib Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\n-->\n\n\n<details>\n  <summary>\n    About stdlib...\n  </summary>\n  <p>We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.</p>\n  <p>The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.</p>\n  <p>When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.</p>\n  <p>To join us in bringing numerical computing to the web, get started by checking us out on <a href=\"https://github.com/stdlib-js/stdlib\">GitHub</a>, and please consider <a href=\"https://opencollective.com/stdlib\">financially supporting stdlib</a>. We greatly appreciate your continued support!</p>\n</details>\n\n# replace\n\n[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->\n\n> Replace search occurrences with a replacement string.\n\n<section class=\"installation\">\n\n## Installation\n\n```bash\nnpm install @stdlib/string-base-replace\n```\n\n</section>\n\n<section class=\"usage\">\n\n## Usage\n\n```javascript\nvar replace = require( '@stdlib/string-base-replace' );\n```\n\n#### replace( str, search, newval )\n\nReplaces search occurrences with a replacement string.\n\n```javascript\nvar out = replace( 'beep', /e/g, 'o' );\n// returns 'boop'\n```\n\nIf provided a function as the third argument, the function is invoked for each match, and the function's return value is used as the replacement string.\n\n```javascript\nfunction replacer( match, p1 ) {\n    return '/' + p1 + '/';\n}\nvar str = 'Oranges and lemons';\nvar out = replace( str, /([^\\s]+)/gi, replacer );\n// returns '/Oranges/ /and/ /lemons/'\n```\n\n</section>\n\n<!-- /.usage -->\n\n<section class=\"notes\">\n\n## Notes\n\n-   The function assumes that the `search` argument is a [regular expression][mdn-regexp]. Accordingly, the function should **not** be used as a general drop-in replacement for [`String.prototype.replace`][mdn-string-replace].\n\n</section>\n\n<!-- /.notes -->\n\n<section class=\"examples\">\n\n## Examples\n\n<!-- eslint no-undef: \"error\" -->\n\n```javascript\nvar capitalize = require( '@stdlib/string-base-capitalize' );\nvar replace = require( '@stdlib/string-base-replace' );\n\nvar out = replace( 'Hello World', /world/i, 'Mr. President' );\n// returns 'Hello Mr. President'\n\nfunction replacer( match, p1 ) {\n    return capitalize( p1 );\n}\nvar str = 'Oranges and lemons say the bells of St. Clement\\'s';\nout = replace( str, /([^\\s]*)/gi, replacer );\n// returns 'Oranges And Lemons Say The Bells Of St. Clement\\'s'\n```\n\n</section>\n\n<!-- /.examples -->\n\n<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->\n\n<section class=\"related\">\n\n* * *\n\n## See Also\n\n-   <span class=\"package-name\">[`@stdlib/string-base/replace-after`][@stdlib/string/base/replace-after]</span><span class=\"delimiter\">: </span><span class=\"description\">replace the substring after the first occurrence of a specified search string.</span>\n-   <span class=\"package-name\">[`@stdlib/string-base/replace-before`][@stdlib/string/base/replace-before]</span><span class=\"delimiter\">: </span><span class=\"description\">replace the substring before the first occurrence of a specified search string.</span>\n-   <span class=\"package-name\">[`@stdlib/string-base/replace-after-last`][@stdlib/string/base/replace-after-last]</span><span class=\"delimiter\">: </span><span class=\"description\">replace the substring after the last occurrence of a specified search string.</span>\n-   <span class=\"package-name\">[`@stdlib/string-base/replace-before-last`][@stdlib/string/base/replace-before-last]</span><span class=\"delimiter\">: </span><span class=\"description\">replace the substring before the last occurrence of a specified search string.</span>\n\n</section>\n\n<!-- /.related -->\n\n<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->\n\n\n<section class=\"main-repo\" >\n\n* * *\n\n## Notice\n\nThis package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.\n\nFor more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib].\n\n#### Community\n\n[![Chat][chat-image]][chat-url]\n\n---\n\n## License\n\nSee [LICENSE][stdlib-license].\n\n\n## Copyright\n\nCopyright &copy; 2016-2026. The Stdlib [Authors][stdlib-authors].\n\n</section>\n\n<!-- /.stdlib -->\n\n<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->\n\n<section class=\"links\">\n\n[npm-image]: http://img.shields.io/npm/v/@stdlib/string-base-replace.svg\n[npm-url]: https://npmjs.org/package/@stdlib/string-base-replace\n\n[test-image]: https://github.com/stdlib-js/string-base-replace/actions/workflows/test.yml/badge.svg?branch=v0.2.3\n[test-url]: https://github.com/stdlib-js/string-base-replace/actions/workflows/test.yml?query=branch:v0.2.3\n\n[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/string-base-replace/main.svg\n[coverage-url]: https://codecov.io/github/stdlib-js/string-base-replace?branch=main\n\n<!--\n\n[dependencies-image]: https://img.shields.io/david/stdlib-js/string-base-replace.svg\n[dependencies-url]: https://david-dm.org/stdlib-js/string-base-replace/main\n\n-->\n\n[chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg\n[chat-url]: https://stdlib.zulipchat.com\n\n[stdlib]: https://github.com/stdlib-js/stdlib\n\n[stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors\n\n[umd]: https://github.com/umdjs/umd\n[es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules\n\n[deno-url]: https://github.com/stdlib-js/string-base-replace/tree/deno\n[deno-readme]: https://github.com/stdlib-js/string-base-replace/blob/deno/README.md\n[umd-url]: https://github.com/stdlib-js/string-base-replace/tree/umd\n[umd-readme]: https://github.com/stdlib-js/string-base-replace/blob/umd/README.md\n[esm-url]: https://github.com/stdlib-js/string-base-replace/tree/esm\n[esm-readme]: https://github.com/stdlib-js/string-base-replace/blob/esm/README.md\n[branches-url]: https://github.com/stdlib-js/string-base-replace/blob/main/branches.md\n\n[stdlib-license]: https://raw.githubusercontent.com/stdlib-js/string-base-replace/main/LICENSE\n\n[mdn-string-replace]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace\n\n[mdn-regexp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp\n\n<!-- <related-links> -->\n\n[@stdlib/string/base/replace-after]: https://www.npmjs.com/package/@stdlib/string-base-replace-after\n\n[@stdlib/string/base/replace-before]: https://www.npmjs.com/package/@stdlib/string-base-replace-before\n\n[@stdlib/string/base/replace-after-last]: https://www.npmjs.com/package/@stdlib/string-base-replace-after-last\n\n[@stdlib/string/base/replace-before-last]: https://www.npmjs.com/package/@stdlib/string-base-replace-before-last\n\n<!-- </related-links> -->\n\n</section>\n\n<!-- /.links -->\n","_attachments":{},"homepage":"https://stdlib.io","bugs":{"url":"https://github.com/stdlib-js/stdlib/issues"},"license":"Apache-2.0"}