【发布时间】:2016-08-28 16:11:19
【问题描述】:
鉴于以下键值对,我如何仅匹配值(包括引号)?
说明:我正在我的 IDE 中进行查找和替换。我有数百个键/值对,其中的值需要从字符串更改为对象。所以基本上替换了值。
"ElevationFilenameIn": "Input raster elevation file",
"TargetCRS": "Target vertical coordinate reference system Type",
"featureName": "The name of the feature to extract, for example \"Vegetation\" or \"Water\"",
"TargetCRScode": "Target vertical coordinate system Code",
"TargetCRSfile": "The projection (.prj) file in shoebox to be used for this inputfile"
My attempt(不工作,甚至关闭):
[:]\s*(\"\w*\")
【问题讨论】:
-
您可以使用 ("(.*?)") 但我怀疑这是否是您真正需要/想要的
-
不需要将冒号括起来,甚至不需要将它包含在正则表达式中。这应该可以...
(\".*\"),不要忘记在替换中添加尾随逗号。 -
@user6188402 是的,这也有可能。我已更新我的问题以包含转义引号。
标签: javascript regex