1. the text file contains key characters such as " and \
Can I assign a variable to this file, even though it contains reserved characters? If this poses a problem, I was thinking about writing a function to go through the text file, and when it catches a reserved character, [namely " and \] then it adds escape characters to it. So if it finds j = "5", it will change it into j = \"5\". So something like:
I have written some more pseudo code . Please help with the actual code.
//goes through the entire text file
if a character == "\""
add escape character "\" in front;
if a character == "\"
add escape characters "\\" in front;
var pattern = [some regular expression] //needs actual code
var file = [statement to assign this variable to a file, or something like this] //needs actual code
parsedTxt = pattern.exec(file); //runs the pattern against the original file
document.write(parsedTxt); //prints the parsed text