![](/img/trans.png)
[英]How to convert this String to JSON object in Javascript, when the string has single quote within the double quote
[英]Double quote string escape node eval javascript
我有一個節點文件,其中包含以下內容:
console.log("hello \"\"world")
當我登錄時,我得到:
hello ""world
我想把它放在節點的-e(eval)標志中。
從概念上講,我並不理解如何“清理”此字符串,以便產生相同的輸出。
node -e "console.log(\"hello \\"\\"world\")"
hello \world
這有效,但增加了一個斜線
為了使eval有效並按預期工作,我將如何處理它的內容?
您還需要兩個斜杠:
node -e "console.log(\"hello \\\"\\\"world\")"
\\
和"
需要轉義。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.