Skip to content

Instantly share code, notes, and snippets.

@kieranbarker
Created July 19, 2020 07:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kieranbarker/17188e65499b6731801b42cc01214fe2 to your computer and use it in GitHub Desktop.
Save kieranbarker/17188e65499b6731801b42cc01214fe2 to your computer and use it in GitHub Desktop.
Escape double and single quotes inside a string
/**
* Escape double and single quotes inside a string
* @param {String} string The string
* @returns {String} The string with quotes escaped
*/
function escapeQuotes (string) {
return string.replace(/"/g, """).replace(/'/g, "'");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment