1var str = 'remove "foo" delimiting double quotes';
2console.log(str.replace(/"([^"]+(?="))"/g, '$1'));
3//logs remove foo delimiting quotes
4str = 'remove only "foo" delimiting "';//note trailing " at the end
5console.log(str.replace(/"([^"]+(?="))"/g, '$1'));
6//logs remove only foo delimiting "<-- trailing double quote is not removed
7
1if (str.charAt(0) === '"' && str.charAt(str.length -1) === '"')
2{
3 console.log(str.substr(1,str.length -2));
4}
5
1var someStr = 'He said "Hello, my name is Foo"';
2console.log(someStr.replace(/['"]+/g, ''));
3