For instance say I have the string:
var name = 'Mc'Obrian'
I want to be able to escape the the first quote and the last quote only, not the quote used within the name, how can I achieve this in javascript? thanks
For instance say I have the string:
var name = 'Mc'Obrian'
I want to be able to escape the the first quote and the last quote only, not the quote used within the name, how can I achieve this in javascript? thanks
The following will properly escape the single quote given your current code:
var name = 'Mc\'Obrian'
I would encourage you to read the following tutorial about strings. If you are interested in performance considerations, read this question.