@kingjs/string-ex.replace-all
v1.0.0
Published
Returns a new string in which all occurrences of a substring are replaced with another string.
Downloads
11
Readme
@kingjs/string-ex.replace-all
Returns a new string in which all occurrences of a substring are replaced with another string.
Usage
var assert = require('assert');
var ReplaceAll = require('@kingjs/string-ex.replace-all');
var result = "fooBarFooBar"[ReplaceAll]('Bar', 'Moo');
assert(result == 'fooMooFooMoo');
API
replaceAll(this, oldValue, newValue)
Parameters
this
: The string to search and replace.oldValue
: The string to be replaced.newValue
: The string to replace all occurrences ofoldValue
.
Returns
A string that is equivalent to the current string except that all instances of oldValue
are replaced with newValue
.
Install
With npm installed, run
$ npm install @kingjs/string-ex.replace-all
Source
https://repository.kingjs.net/string-ex/replace-all
License
MIT