javascript remove quotes from string

Posted by Paidboom - 2 months ago

javascript remove quotes from string

var someStr = 'He said "Hello, my name is Foo"';
console.log(someStr.replace(/['"]+/g, ''));

Which is displayed as quotes in a browser as shown below. This prevents additional quotes from terminating the string and causing javascript or html errors.