Problem: I have a data dump of a MongoDb query in a JSON file. I need to replace the ObjectID(“12345677abc”) with “12345677abc”.
Using Visual Studio Code’s find and replace
Find:
ObjectId\("([0-9a-fA-F]{24})"\)
Replace with: “$1”
Turns this
"_id" : ObjectId("5e3b1890e032d225a091d43f"),
"userId" : ObjectId("65ed1c2c-922c-4c82-b5bc-7324f69eea10"),
To this
"_id" : "5e3b1890e032d225a091d43f",
"userId" : "65ed1c2c-922c-4c82-b5bc-7324f69eea10",
Bonus:
ISODate\("([^"]+)"\)