showing results for - "how to remove quotes using regex"
Jonathan
23 May 2016
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
Florencia
22 Apr 2019
1str.replace(/^"(.+(?="$))"$/, '$1');
2
Claudia
30 Jun 2016
1if (str.charAt(0) === '"' && str.charAt(str.length -1) === '"')
2{
3    console.log(str.substr(1,str.length -2));
4}
5
Federica
13 Feb 2017
1var someStr = 'He said "Hello, my name is Foo"';
2console.log(someStr.replace(/['"]+/g, ''));
3
Violeta
17 Aug 2017
1str.replace(/^["'](.+(?=["']$))["']$/, '$1');
2
Henry
25 Apr 2017
1someStr.replace(/^"(.+)"$/,'$1');
2