【问题标题】:Getting information inside double quotes [duplicate]在双引号内获取信息[重复]
【发布时间】:2021-10-29 17:35:50
【问题描述】:

我正在尝试在 node.js 中的引号内获取信息

例如:

var information = 'Hello "beautiful and amazing" world.'

如何记录" " 中写入的内容? 我想得到这个结果:beautiful and amazing

【问题讨论】:

    标签: javascript node.js


    【解决方案1】:

    使用正则表达式:

    var information = 'Hello "beautiful and amazing" world.'
    var regex = /".+"/
    var match = information.match(regex)
    var res = match?.[0].slice(1, match[0].length - 1)
    console.log("Result: " + res)

    这会检查",然后是任何文本,然后是另一个"。然后它删除"s

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-12-17
      • 1970-01-01
      • 2021-05-16
      • 2018-07-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多