blazinazian
blazinazian

Reputation: 305

Replacing " with \" in ASP

As the title suggests, I am trying to replacing a " with the escape character \". The reason I am doing this is because there is a quote in my string that represents inches and this string needs to be run through javascript code.

However, when I run my string in the javascript code, it only reads up to the inches character and forgets the rest of the string.

Any and all help is greaty appreciated.

Upvotes: 2

Views: 1159

Answers (2)

guuds.com
guuds.com

Reputation: 47

If you define like this var s = 'some string';, the quote is work ok, but if you do like var s = "some string";, you should replace the quote to \", so the code is var s = "some string \ " with the quote"; also you need to replace the Vbcrlf and vbcr and vblf before the JS code

Upvotes: 0

Flash
Flash

Reputation: 16743

A function like this will escape \, " and ':

function AddSlashes(str)
    AddSlashes = replace(str,"\","\\")
    AddSlashes = replace(AddSlashes,"'","\'")
    AddSlashes = replace(AddSlashes,chr(34),"\" & chr(34))
end function

Source

Upvotes: 2

Related Questions