Reputation: 3999
I am trying to replace ',",\ characters with blank.
I use the following code
jQuery.get('/path to file/file.txt',function(data){
data = data.replace(/\'\"\\/g," ");
alert(data);
})
but nothing replaced.
Where am I wrong?
Upvotes: 2
Views: 163
Reputation: 270637
Your expression would replace the 3 character sequence '"\
with a space, not the individual chars \
, '
and "
. Enclose them in a character class []
(and there's no need to escape with \
except for the \
).
data = data.replace(/['"\\]/g," ");
// Example:
var str = "This string has internal \" double \\ quotes \\ and 'some single ones' and a couple of backslashes";
str = str.replace(/['"\\]/g," ");
// Output: all quotes replaced with spaces:
// "This string has internal double quotes and some single ones and a couple of backslashes"
Upvotes: 1
Reputation: 4947
you are wrong. there is nothing to replace.
regex does not open any file. all it does is replacing the char combination '"
with whitespace.
what you search for is ['"]
instead of \'\"
Upvotes: 1