replace

最后更新于:2022-04-02 00:07:24

## 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' ```
';