1var someStr = 'He said "Hello, my name is Foo"';
2console.log(someStr.replace(/['"]+/g, ''));
1function escapeHTML(text) {
2 var replacements= {"<": "<", ">": ">","&": "&", """: """};
3 return text.replace(/[<>&"]/g, function(character) {
4 return replacements[character];
5 });
6}
1var string = 'this isn\'t a double quoted string';
2var string = "this isn\"t a single quoted string";
3// ^ ^ same types, hence we need to escape it with a backslash