AI写作智能体 自主规划任务,支持联网查询和网页读取,多模态高效创作各类分析报告、商业计划、营销方案、教学内容等。 广告
## 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' ```