【发布时间】:2021-10-29 17:35:50
【问题描述】:
我正在尝试在 node.js 中的引号内获取信息
例如:
var information = 'Hello "beautiful and amazing" world.'
如何记录" " 中写入的内容?
我想得到这个结果:beautiful and amazing
【问题讨论】:
标签: javascript node.js
我正在尝试在 node.js 中的引号内获取信息
例如:
var information = 'Hello "beautiful and amazing" world.'
如何记录" " 中写入的内容?
我想得到这个结果:beautiful and amazing
【问题讨论】:
标签: javascript node.js
使用正则表达式:
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
【讨论】: