I keep getting the following error
Uncaught SyntaxError: Invalid regular expression: /$_POST['/: Unterminated character class
I searched a few threads and they all pointed me to the fact the at I am not properly escaping the string. I loaded a php file into a javascript var as a string , then I search through it for the following, but I have tried escaping to no success.
according to List of all characters that should be escaped before put in to RegEx?
These are all the characters that need escaping I believe.
. \ + * ? [ ^ ] $ ( ) { } = ! < > | : -
and here are the code snipets that are failing me. (This is the clean code everything needs escaping)
var n = data.search("$_POST['");
n = res.search("'];");
n = data.search("//hurdle{");
n = res.search("}");
If someone could show me how to properly do this, it would be very appreciated. Thank you