mrblah
mrblah

Reputation: 103497

Do I need to escape these in javascript?

My strings will hold the values:

"["
"[/blah]"

do I need to escape anything?

Is it just doubling the /?

Upvotes: 0

Views: 259

Answers (3)

Trav L
Trav L

Reputation: 15192

If your string are "[" "[/blah]", then you don't need to escape anything if you use single quote:

var foo = '"[" "[/blah]"';

Upvotes: 2

Bostone
Bostone

Reputation: 37126

Since this is a literal string square brackets or forward slash will not be interpreted so in your example you don't need to escape anything. Doubling applies to a backward slash only \

Upvotes: 1

Marek Karbarz
Marek Karbarz

Reputation: 29304

you don't have to do anything / is not a special character

Upvotes: 4

Related Questions