Find value in line and delete that line and previous line?
-
Is it possible to find a value (or match a whole line) and if that value matches, delete that line and the previous line. The real question is can I delete the “previous” line?
For example…
Testing archive: archive01.zip <--- this line will be deleted if next line matches Everything is Ok <-- match this line then delete this line and the previous line Testing archive: archive02.zip Sub items Errors: 1 Testing archive: archive03.zip <--- this line will be deleted if next line matches Everything is Ok <-- match this line then delete this line and the previous line Testing archive: archive04.zip Sub items Errors: 1 Testing archive: archive05.zip <--- this line will be deleted if next line matches Everything is Ok <-- match this line then delete this line and the previous lineleaving me with…
Testing archive: archive02.zip Sub items Errors: 1 Testing archive: archive04.zip Sub items Errors: 1I would appreciate ANY help!
Thank you.
-
Sure, something like this should work:
find:
(?-is)^.+\REverything is Ok\R
repl: nothing
search mode: Regular expression -
That is EXACTLY what I was looking for! Thank you very very much!
I have tried so many interactions of similar syntax, but in the end… my regex just sucks! ;)
Thank you again!
-
@Phat-Lix said in Find value in line and delete that line and previous line?:
my regex just sucks! ;)
-
Oh geez! That is a fantastic collection. Thank you.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login