1 var toString = require('./toString');
4 * Replaces matches for `pattern` in `string` with `replacement`.
6 * **Note:** This method is based on [`String#replace`](https://mdn.io/String/replace).
11 * @param {string} [string=''] The string to modify.
12 * @param {RegExp|string} pattern The pattern to replace.
13 * @param {Function|string} replacement The match replacement.
14 * @returns {string} Returns the modified string.
17 * _.replace('Hi Fred', 'Fred', 'Barney');
22 string = toString(args[0]);
24 return args.length < 3 ? string : string.replace(args[1], args[2]);
27 module.exports = replace;