Martin46766474
04-09-2003, 07:09 PM
I'm trying to find an easy way to search a string and if a single quote is found, replace it with \'
So:
var a = "It's doing my head in!"
OR
var a = "I can't do it - it's too hard."
How can I turn either of those into:
It\'s doing my head in!
OR
I can\'t do it - it\'s too hard.
Cheers.
Edit: I cant just use:
var a = "I can\'t do it - it\'s too hard."
'a' will get its value from a form when I'm done testing so I won't know if or where in the string an apostrophe will be used.
So:
var a = "It's doing my head in!"
OR
var a = "I can't do it - it's too hard."
How can I turn either of those into:
It\'s doing my head in!
OR
I can\'t do it - it\'s too hard.
Cheers.
Edit: I cant just use:
var a = "I can\'t do it - it\'s too hard."
'a' will get its value from a form when I'm done testing so I won't know if or where in the string an apostrophe will be used.