保持节点在保存字符串时不剥离反斜杠(转义斜杠)?

huangapple go评论64阅读模式
英文:

Keep node from stripping \ (Escape slashes) when saving strings?

问题

我有一个包含以下内容的字符串模板:

    "echo": "echo \"$PWD\""

当我将模板保存到文件系统时,Node.js会删除转义字符(\),所以上述情况下的输出将是:

    "echo": "echo "$PWD""

我们如何阻止Node.js删除转义字符?

英文:

I have a string template that includes the following:

    "echo": "echo \"$PWD\""

When I save the template to the file system, node strips out the escape characters ( \ ), so that in the above case the output would be:

    "echo": "echo "$PWD""

How do we keep node from stripping the escape characters?

答案1

得分: -1

这起初是起作用的(逃避转义字符)!谢谢Andy!!

"echo": "echo \\\"$PWD\\\""
英文:

This ended up doing the trick (Escape the escape character)! Thanks Andy!!

"echo": "echo \\"$PWD\\""

huangapple
  • 本文由 发表于 2023年4月17日 01:08:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/76029216.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定