Lodash replace method
语法
_.replace([string=''], pattern, replacement)
Replaces matches for pattern in string with replacement.
参数
[string=''] (string) − The string to modify.
pattern (RegExp|string) − The pattern to replace.
replacement (Function|string) − The match replacement.
输出
(string) − Returns the modified string.
实例
var _ = require('lodash');
var result = _.replace('Hi Joe', 'Joe', 'Julie');
console.log(result);
Save the above program in
tester.js. Run the following command to execute this program.
Command
输出