简体   繁体   中英

javascript split / join character within quotes

I have some text and need to replace all instances of a character within quotes " z6 " and replace with " / " I'm not sure how to include quotes within quotes:

text = text.split("" z6 "").join("" / "");

Escape using backslash

text = text.split("\" z6 \"").join("\" / \"");

Or template strings:

text = text.split(`" z6 "`).join(`" / "`);

Or single quotes

text = text.split('" z6 "').join('" / "');

You can use single quotes and double quotes interchangeably. To solve your specific problem:

text = text.split('" z6 "').join('" / "');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM