Node.js String Escape Characters Translation
The first case, I have use the fs.readFileSync() to read html content from the local file, and I call the console.log(),it output normally with format. The second case,I use the r
Solution 1:
Replace the escape characters using the Javascript replace method String.replace()
var newString = $3.replace(/\\n|\\/g,"");
console.log(newString);
Generally speaking, you can parse special charachters by putting an extra "\" before them. For example if you wanted to refer to "\n" in a string literally, you can use "\n". To replace any of the special characters in a string, do;
var newString = $3.replace(/\\n|\\/g,"string-you-want-to-replace-with");
console.log(newString);
Post a Comment for "Node.js String Escape Characters Translation"