_.replace

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

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'
doc_Lodash
2016-11-27 16:40:05
Comments
Leave a Comment

Please login to continue.