Answers for "file system replace line js"

1

file system replace line js

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);
  });
});
Posted by: Guest on November-16-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language