astralaaron Posted May 15, 2011 Share Posted May 15, 2011 I've been having trouble with this. Will someone point out my error? I searched around and nothing I found worked.varA = "it's a test, it's a test";*one example I've triedvarB = varA.replace(/\'/g, "\'");*another example...varB = varA.replace(/'/g, "\'");(trying to get "it\'s a test, it\'s a test" to output)varB = varA.replace(/(['])/g, "\\\'"); ended up working like I need... thanks anyway! Link to comment Share on other sites More sharing options...
jeffman Posted May 15, 2011 Share Posted May 15, 2011 It can be a little less complicated:varA.replace(/'/g, "\\'"); Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.