📜  文件系统替换行 js - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:14.480000             🧑  作者: Mango

代码示例1
var fs = require('fs')
fs.readFile(someFile, 'utf8', function (err,data) {
  if (err) {
    return console.log(err);
  }
  var result = data.replace(/string to be replaced/g, 'replacement');

  fs.writeFile(someFile, result, 'utf8', function (err) {
     if (err) return console.log(err);
  });
});