【问题标题】:how do I create a string with an escaped open parens?如何创建带有转义开放括号的字符串?
【发布时间】:2022-06-30 19:47:08
【问题描述】:

考虑以下

➜ ~ node
Welcome to Node.js v16.15.1.
Type ".help" for more information.
> s = '('
'('
> s = '\('
'('
> s = '\\('
'\\('
> s = String.raw`(`
'('
> s = String.raw`\(`
'\\('
> s = String.raw`\\(`
'\\\\('

那么,如何将s 设置为'\('

【问题讨论】:

  • 你把“价值”和“表现”搞混了

标签: javascript string


【解决方案1】:

使用 \r :

const s = "\\r("

【讨论】:

    猜你喜欢
    • 2016-03-15
    • 2015-10-27
    • 1970-01-01
    • 2014-01-24
    • 1970-01-01
    • 2010-12-16
    • 1970-01-01
    • 2019-06-29
    • 1970-01-01
    相关资源
    最近更新 更多