10 examples of 'remove quotes from string javascript' in JavaScript

Every line of 'remove quotes from string javascript' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
28function removeQuotes(string) {
29 if (typeof string === 'string' || string instanceof String) {
30 string = string.replace(/^['"]+|\s+|\\|(;\s?})+|['"]$/g, '');
31 }
32 return string;
33}
357function removeQuotes(value) {
358 if (value.length > 1 && (value[0] === "'" || value[0] === '"')) {
359 return value.substr(1, value.length - 2);
360 }
361 return value;
362}
106function stripQuotes(str) {
107 if (str.length === 0) {
108 return str;
109 }
110 if (str.charAt(0) === "\"" && str.charAt(str.length - 1)) {
111 return str.substring(1, str.length - 1);
112 }
113 return str;
114}
50export function quotes(value:string):string {
51 return value.replace(/((?:[^\\']|\\.)+)|(')/g, function ($0, $1, $2) {
52 return $2 ? "\\'" : $1;
53 });
54}
9export function escapeQuotes(value, defaultValue = '') {
10 return value ? value.replace(/(^|[^\\])"/g, '$1\\\"') : defaultValue;
11}
43function escapeSingleQuote (string) {
44 if (typeof string !== 'string') {
45 return string
46 }
47 return string.replace(/'/g, '\\\'')
48}
205function strip_quotes(s) { return s.slice(1, -1); }
51export function escapeDoubleQuotes(string) {
52 return string.replace(/\"/g, '\\$&');
53}
1export function escapeQuotes(input: string) {
2 // double escape quotes so that they are not unescaped completely in the template string
3 return input.replace(/"/g, '\\"');
4}
23export function removeQuotesFromKeys (str) {
24 return str.replace(/"([^(")"]+)":/g,"$1:")
25}

Related snippets