_.replace(字符串替换)
语法:
_.replace([string=''], pattern, replacement)源代码链接:source
npm包链接:npm package
描述:
替换string字符串中匹配的pattern为给定的replacement。
注意:这个方法基于
String#replace。可使用正则替换。
开始版本:4.0.0
参数:
[string=''] (string): 待替换的字符串。pattern (RegExp|string): 要匹配的内容。replacement (Function|string): 替换的内容。
返回值:
(string): 返回替换后的字符串
例子:
_.replace('Hi Fred', 'Fred', 'Barney');
// => 'Hi Barney'Last updated
Was this helpful?