Escaping Strings in JavaScript
Posted
by Steve Harrison
on Stack Overflow
See other posts from Stack Overflow
or by Steve Harrison
Published on 2009-04-20T23:50:45Z
Indexed on
2010/03/31
18:53 UTC
Read the original article
Hit count: 412
Hello,
Does JavaScript have a built-in function like PHP's addslashes
(or addcslashes
) function to add backslashes to characters that need escaping in a string?
For example, this:
This is a demo string with 'single-quotes' and "double-quotes".
...would become:
This is a demo string with \'single-quotes\' and \"double-quotes\".
Thanks,
Steve
© Stack Overflow or respective owner