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
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The following will properly escape the single quote given your current code:
I would encourage you to read the following tutorial about strings. If you are interested in performance considerations, read this question.