so I have the following line of javascript:
YAHOO.lang.JSON.parse(txt)
where text is a string that is pulled from the database. This is an example of one of the problem strings I'm getting back:
5000\25\30%
The JSON parser is throwing syntax errors on the / character as far as I can tell. I looked through threads here and most of them are saying to change it to "//" but I'm pulling hundreds of values from a database so I can't change their source. I'm trying to get it to replace the '/' char with just the empty string since I don't actually have to display the '/', but I'm having difficulties. My current replace code looks like this:
if(substr.indexOf("\\") > 0){
substr.replace(/\\/g , "");
}
but nothing is happening. Sometimes the "indexOf" check fails, so I tried running the replace on every string and it still didn't replace any of the '\' chars. So here is my question: If I get back a string with one or more '\' characters and need to remove them for a JSON parser using javascript, how do I do that; or how do I get a JSON parser to accept the '\' char without changing the source string.
Edit: I think what might be the problem is that "\2" and all the other ones are evaluating and exceping characters that don't do anything. These characters are always escaped so they cannot be replaced. Is this even possible to fix the error?