Pages

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.

6 comments:

  1. thanks, its working for me

    ReplyDelete
  2. ....I forget that one, too. Thanks!

    ReplyDelete
  3. It workerd amazingly well

    ReplyDelete
  4. It worked really well...Thanks a ton

    ReplyDelete
  5. It's not working for me guide me please

    ReplyDelete
  6. it working really file to remove quotes in integration

    ReplyDelete