# lodash replace
替换 string 字符串中匹配的 pattern 为给定的 replacement。
概要
_.replace([string=''], pattern, replacement)
替换 string 字符串中匹配的 pattern 为给定的 replacement。
注意: 这个方法基于 String#replace .
添加版本
4.0.0
参数
[string=''] (string): 待替换的字符串。pattern (RegExp|string): 要匹配的内容。replacement (Function|string): 替换的内容。
返回 (string): 返回替换后的字符串
例子
_.replace('Hi Fred', 'Fred', 'Barney');
// => 'Hi Barney'
← _.repeat _.snakeCase →