1

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!

IvoL
  • 93
  • 1
  • 8
  • You could include all seven lines of each record in the regex and use capture groups to replace only the last three. – Yannic Aug 04 '20 at 07:44
  • You could capture what you want to keep and match the 3 lines after that to remove them https://regex101.com/r/ydk8Dt/1 – The fourth bird Aug 04 '20 at 07:47
  • Check this on how to back reference captured groups: https://riptutorial.com/notepadplusplus/example/27189/referencing-capture-groups – Yannic Aug 04 '20 at 07:47

2 Answers2

0

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

The fourth bird
  • 154,723
  • 16
  • 55
  • 70
0

Try this ...

Find what: filter((.*\n){4})[\s\S]*?step.*\s?
Replace with: $1

Or this, both are working for me...

Find what: filter[\s\S]*?step.*\K[\s\S]*?step.*?"
Replace with: nothing

Haji Rahmatullah
  • 390
  • 1
  • 2
  • 11