gpt4 book ai didi

Javascript 正则表达式匹配 JSON 键值对的值

转载 作者:行者123 更新时间:2023-11-30 07:02:05 25 4
gpt4 key购买 nike

给定以下键值对,我如何才能只匹配值(包括引号)?

说明:我正在我的 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*\")

最佳答案

你可以使用模式:

[:]\s(\".*\")

并通过此链接对其进行测试:https://regex101.com/r/nE5eV3/1

关于Javascript 正则表达式匹配 JSON 键值对的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37007112/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com