SyntaxFix
Write A Post
Hire A Developer
Questions
var str = "This is a single quote: ' and so is this: '"; console.log(str); var replaced = str.replace(/'/g, "\\'"); console.log(replaced);
Gives you:
This is a single quote: ' and so is this: ' This is a single quote: \' and so is this: \'