Skip to main content

replace

_.replace(pattern, replacement, string) # Ⓢ [Ⓣ][1] Ⓝ

Replaces matches for pattern in string with replacement.





Note: This method is based on



String#replace.

Since​

4.0.0

Arguments​

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

Returns​

(string): Returns the modified string.

Example​

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