Escaped quotes - are there any other characters that can be used?

I understand quotes, etc. for javascript. Are there any other characters that can be used to put all of this, and not just "or"? Both characters will be displayed in my piece of text, and I don't want it to be placed / in front of each instance

So, instead of:

("Some text where he said "I like this, she say's") 

something like this (although I do not expect the use of a percent sign)

 (%Some text where he said "I like this, she say's% 

Hope this is a little reasonable! Thanks.

+4
source share
3 answers

Literal strings must be declared using " or ' . And in such a declaration, the quotation marks that surround the string value must be escaped. So:

 "Some text where he said \"I like this, she say's" 'Some text where he said "I like this, she say\'s' 

Both will be interpreted as:

 Some text where he said "I like this, she say's 
+1
source

Not. Only " and ' are valid line separators. You should avoid them either as

 "...\"...'..."; '..."...\'...'; 

(As a cheat, you can put the string in a hidden <div> and read the textContent in JS.)

(Like another cheat, /Some text where he said "I like this, she say's/.source .)

0
source

If you work with content that comes from your server-side template language, you may also need to worry about coding multi-byte sequences and β€œcheck” characters.

0
source

Source: https://habr.com/ru/post/1302491/


All Articles