Home > Blockchain >  Remove delimiter from text variable while reading
Remove delimiter from text variable while reading

Time:05-27

i received this file form the server and stored it automatically
Text file chall.txt :

"rnIgOUXql5SEgpYy6vul"

JAVASCRIPT :

const fs = require('fs');
var challange = fs.readFileSync('chall.txt', 'utf8');

i want that variable to be stored like this rnIgOUXql5SEgpYy6vul not this "rnIgOUXql5SEgpYy6vul"
so i don't need every time open txt and remove delimiters

CodePudding user response:

Replace the quotes.

const fs = require('fs');
let content = fs.readFileSync('chall.txt', 'utf-8');
content = content.replace('"', '');

CodePudding user response:

So, you will do like this :

const fs = require('fs');
var challange = await fs.readFileSync('chall.txt', 'utf8');
let data = challenge.replace("\"", "");
  • Related