我有一个 JS 字符串,其中包含双引号之间的文本 ("
)。我想使用正则表达式将该文本替换为另一个用户输入的文本,但我不知道该怎么做。例如:
给定字符串:
The book "A Farewell to Arms" will be published again.
新文本:飘 --> 上面的句子将是
The book "Gone with the Wind" will be published again.
你能帮我解决这个案子吗?很抱歉这个虚拟问题,因为我是 JS RegEx 的新手。
这应该可以做到。.请原谅我的打字错误。我不是 javascript 开发人员
str.replace(/".*?"/,"\"Gone with the Wind\"");
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)