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