Regex – how to remove specific string from a long file


I have this json file with this data:

"json": {
    "3.0": {
        "path": "sfsdfsdfsf",
        "release": {
            "id": 14211,
            "version": "2017061400",
            "release": "sdfsdfsfd",
            "maturity": 200,
            "downloadurl": "sfdfsfdfds",
            "downloadmd5": "sffsdfs",
            "vcssystem": "git",
            "vcssystemother": null,
            "vcsrepositoryurl": "dsfdsfsdf",
            "vcsbranch": null,
            "vcstag": "v1.6",
            "timecreated": 1497462295,
            "test": [
                    "version": 2015102300,
                    "release": "3.0"
        "file": "fsdfdsfsd",
        "url": "sdfsdfsdf"

And I need a way in my editor using regex to remove this first "release" object. I was trying to figure it out but not successful to get rid of it.

I tried a lot of things for example:

"release": {([^}]+)\},

This will remove all till the first closing curly bracket, but don’t know how to come to remove everything until this "file" section.
How to tell regex, go on, until you find the file section?

>Solution :

while regexes are not the right tools for this, it can be done using a regex.

see: regex

The used regex: ("release": {[ "a-zA-Z:0-9,\r\n\.[{}\]]*)(?="file")

  • Match "release": {
  • then match any chcaracters like "a-zA-Z:0-9,\r\n\.[{}\] zero or more times.
  • (?="file") do a "positive lookahead" for "file"


A solution using jq (with help from this answer: ):

jq 'walk(if type=="object" then del(.release) else . end)' input.json

Leave a ReplyCancel reply