多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
## replace + [link](./replace "Link to this entry.") + [source](https://github.com/lodash/lodash/blob/4.5.0正式版/lodash.src.js#L12451 "View in source.") + [npm](https://www.npmjs.com/package/lodash.replace "See the npm package.") ``` _.replace([string=''], pattern, 要替换的内容) ``` 替换字符串中匹配的内容为给定的内容 **注意:** 这个方法基于 [`String#replace`](https://mdn.io/String/replace) ### 参数 1. [string=''] (string) 待替换的字符串 2. pattern (RegExp|string) 要匹配的内容 3. 要替换的内容 (Function|string) ### 返回值 (string) 返回替换完成的字符串 ### 示例 ``` _.replace('Hi Fred', 'Fred', 'Barney'); // => 'Hi Barney' ```