Pages

Showing posts with label double quotes replace with. Show all posts
Showing posts with label double quotes replace with. Show all posts

Saturday, March 31, 2012

replace all double quotes in a string javascript

I decided to post this. I always forget syntax for replacing double quotes in javascript.
There are tons of posts for replacing doubles quotes but still tough to find when i need urgently.

//code sample
// this is string with lots of double quotes 
var err = "blahahahah a string with lots of double quotes ";
alert (err);  //  this will alert string with double quotes.

err = err.replace(/\"/g, "");                      
alert (err);  //  this will alert string without  double quotes.



This is a simple regex for replacing all double quotes in javascript.  "/g" is for replacing all double quotes in a string.