_.replace

_.replace([string=''], pattern, replacement)

source npm package

Replaces matches for pattern in string with replacement.

Note: This method is based on String#replace.

Since

4.0.0

Arguments

  1. [string=''] (string): The string to modify.
  2. pattern (RegExp|string): The pattern to replace.
  3. replacement (Function|string): The match replacement.

Returns

(string): Returns the modified string.

Example

_.replace('Hi Fred', 'Fred', 'Barney');
// => 'Hi Barney'