I imported a csv file to JSON to use it it Microsoft GRAPH’s API. I really wanna use the find/replace feature in VScode to replace the double quotes around the integer with nothing so here’s a snip of JSON
{
"displayName": "FirewallRules/12/Action",
"description": null,
"@odata.type": "#microsoft.graph.omaSettingInteger",
"Value": "1",
"omaUri": "./Device/Vendor/MSFT/Firewall/MdmStore/FirewallRules/{firewallrulename}/Action/Type"
},
I even tries using my little knowledge of regex to get it done and had some success using this
^(.*)"\d{1,2}(.*)"$
I wanna ignore "Value", ^(.?)("Value":) and only target "1"
Completely thrown together but I thought it worked, but I cant compensate for the "Value": in front of it. How can I target the Value property’s String value containing an integer with regex? Help please.
>Solution :
You can use
^(\s*"[^"]*"\s*:\s*)"(\d+)"
Replace with $1$2.
See the regex demo. Details:
^– start of a line(\s*"[^"]*"\s*:\s*)– Group 1 ($1): zero or more whitespaces,", zero or more chars other than a double quotation mark,", a:enclosed with zero or more whitespaces"– a"char(\d+)– Group 2 ($2): one or more digits"– a"char