給定以下關鍵值對,我如何才能匹配值(包括引號)?Javascript正則表達式匹配JSON鍵值對的值
說明:我正在查找並替換我的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*\")
加入競爭碼** [MCVE] ** – Tushar
您可以使用['JSON.parse(串)KEY_NAME]'](HTTPS ://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse) –
您可以使用(「(。*?)」),但我懷疑這是否真的需要/想要 – jeff