Last active
July 17, 2019 22:51
-
-
Save adamrosloniec/d3595e6d3341eee3d9a82362627284d1 to your computer and use it in GitHub Desktop.
Node - Remove all special characters from file (.txt, text file, etc)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
fs.readFile("file-with-emoji.txt", "utf-8", (err, data) => { | |
var dataOld = data | |
var dataNew = dataOld.replace(/[^0123456789aąbcćdeęfghijklłmnńoópqrsśtuvwxyzźżAĄBCĆDEĘFGHIJKLŁMNŃOÓPQRSŚTUVWXYZŹŻ\ \!\"\#\$\%\&\'\(\)\+\,\.\/\:\;\<\=\>\?\@\[\]\_\`\{\|\}\–\—\‘\’\‚\“\”\„\…\-]/g, ''); | |
fs.writeFile("file-without-emoji.txt", dataNew, (err) => { | |
console.log("Successfully Written to File."); | |
}); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment