I am looking for a proper version of a JavaScript equivalent of PHP’s addSlashes.
I have found many versions, but none of them handle \b, \t, \n, \f or \r.
To be complete, this jsFiddle should alert: \b\t\n\f\r"\\
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.
Notice how I’ve used
\u0008to replace\bwith\\b. JavaScript’s regex syntax doesn’t appear to accept\b, but it does accept\u0008. JavaScript’s string literal syntax recognises both\band\u0008.