Search code examples
notepad++

Notepad++ delete lines at an interval (e.g. with Skip and Take)


I would like to keep the 1st minQty, maxQty, stepSize but delete the 2nd minQty, maxQty, stepSize. A possible solution in C# would be to take 5 lines and then skip 3 lines. Is there something like this in Notepad++.

Normally i would solve this by bookmarking lines containing a certain strings and then deleting the unbookmarked lines like this (Delete all lines (not) matching a regex using Notepad++). But here this won't work since the strings are the same.

"symbol": "ETHBTC",
                "filterType": "LOT_SIZE",
                "minQty": "0.00100000",
                "maxQty": "100000.00000000",
                "stepSize": "0.00100000"
                "minQty": "0.00000000",
                "maxQty": "9201.00570633",
                "stepSize": "0.00000000"
"symbol": "LTCBTC",
                "filterType": "LOT_SIZE",
                "minQty": "0.01000000",
                "maxQty": "100000.00000000",
                "stepSize": "0.01000000"
                "minQty": "0.00000000",
                "maxQty": "33144.83294363",
                "stepSize": "0.00000000"

Does anybody have an idea? Thanks!


Solution

  • You could capture the lines in a group that you want to keep, starting with filterType and the next 3 lines. Then match the 3 lines after it that you want to remove.

    In the replacement use the first capturing group $1

    ("filterType":\h+"LOT_SIZE",(?:\R\h+"[^"]+":\h+"[^"]+",?){3})(?:\R\h+"[^"]+":\h+"[^"]+",?){3}
    

    Regex demo

    enter image description here