I have a file with name test.txt following data "qwe abc xyz"
And my code is as follows:
let data = fs.readFileSync('test.txt', 'utf8')
console.log(data)
data = data.substring(2) //doing this because first two chars are garbage
console.log(data)
let data2 = data.replace('abc', 'Decimal');
console.log(data2)
Output of this code:
��qwe abc xyz
qwe abc xyz
qwe abc xyz
Why isn't my abc getting replaced with Decimal in data2? I have tried with following as well:
let data = fs.readFileSync('test.txt', 'utf8')
console.log(data)
data = data.substring(2) //doing this because first two chars are garbage
console.log(data)
let data2 = data.replace(/abc/g, 'Decimal');
console.log(data2)
Still it gives the same output. What could be the issue? Can it be related to sync/async?