I write dynamically using a javascript file A (written in node.js) to create a javascript file b I am trying to A from This is the purpose of the string I think the word of this question can be a little misleading. Please tell me whether further explanation is required. In your string, such as .js file b. I want to use regular expression in javascript file. For this, I have to put the regex function for A in the string in A. However, whenever I use it, backslash (escape character) translates the file A as a string, rather than immediately translating the regex function
Var mongodata = "some strings with squares and curly brackets}} {}}},]},} {} {{}}, {[[], [,] [,"; Mongodata = 'var mongodata =' + mongodata + '; \ NFunction SetData () {mongodata = mongodata.replace (/ \ [/ g, ""). Replace (/ \) \}, / g, "& lt; / td> "). Replace (/ \] \} / g, "& lt; / td> & lt; / tr & gt;"); Document.getElementById ("Mongodeta"). InnerHTML = mongoata;} ';
mongodata to be used as the dynamically created
.js file content.
\ N character, all other backslassed expressions Evaluating, so you have to protect yourself from backslash. In other words, a RegExp type that produces a RegExp is the correct way to avoid backslash itself;
\\\ , but you may need to avoid other characters to prevent their evaluation.
No comments:
Post a Comment