Use JavaScript RegEx to match byte value (BOM)
Is there an easy way to use JavaScript regular expressions to conform to the spec? I would like to create a utility that does this in Node.js, but the following doesn't seem like anything:
fixBomFiles : function(offendingFiles) {
var i = 0,
file, js;
for (i=0; i < offendingFiles.length; i++) {
file = offendingFiles[i];
js = this.parent.fs.readFileSync(file, 'utf8');
js = js.replace(/\uFEFF/g, '');
this.parent.fs.writeFileSync(file, js, 'utf8');
}
}
Any ideas? I'm guessing my regex is bad or I shouldn't be using UTF-8 encoding for reading / writing.
+3
source to share