I have a list like following:
ABC
5
0
gdfgdfg
-----------
GHN
3
0
ffffffff
fffff
ffff
trte
-------------
H
1
0
----------------
I would like to delete lines where the line above them starts with a character, and the line below them starts and ends with a zero.
for example above list must convert to following:
ABC
0
gdfgdfg
-----------
GHN
0
ffffffff
fffff
ffff
trte
-------------
H
0
----------------
following regex can select target lines but I don't know how to remove second lines of regex:
^(.+\S)$\R^(\d+)$\R^(0)$
note that second lines must include only a single number between 0-9
You can use
^(.*\S\R)(\d)(\R0)$
Replace with $1$3
. See the regex demo.
It is the same as find ^(.*\S\R)\d(\R0)$
and replace with $1$2
but I kept the third group just in case you need it.
Details
^
- start of a line(.*\S\R)
- Group 1: a line ending with a non-whitespace char and a line break (sequence)(\d)
- Group 2: a digit between 0
and 9
(\R0)
- Group 3: a line break (sequence) and 0
$
- end of a line.See the demo screenshot: