Replace Double Quote In Javascript Variable String
How to replace all double quotes (') instance from a javascript variable string? Here's my code var double_quote_with_string = 'Test 'Double Quote' Test'; var replace_double_quote
Solution 1:
When you try this,
var double_quote_with_string = "Test "Double Quote" Test";
this is syntactically incorrect. If you want quotes in your string try enclosing it in single quotes '
,
var double_quote_with_string = 'Test "Double Quote" Test';
Or use escape character \
var double_quote_with_string ="Test \"Double Quote\" Test";
Solution 2:
var double_quote_with_string = 'Test "Double Quote" Test';
alert(double_quote_with_string );
Solution 3:
check this fiddle. I have replaced all the double quotes with single quotes.
var double_quote_with_string = 'Test "Double Quote" Test';
var replace_double_quote = double_quote_with_string.replace(/"/g, "'");
alert(replace_double_quote);
Post a Comment for "Replace Double Quote In Javascript Variable String"