Replace all multiline text before first appearance of character in multiple files
-
I have found several variations on this question, but none that exactly match what I am trying to do. I am relatively new to Notepad++ and not familiar with the language (so please forgive my ignorance).
I have thousands of text files from which that I need to delete all of the text from the start of the file until the first appearance of a tilde (~) character. The files contain numerous and inconsistent variations on the text that appears before that first ~. Some files may contain 10 lines of random text before the first ~ and others may contain only 3 lines. There is little consistency in what appears in the first n number of lines that I want to delete. This needs to work with Find In Files
Examples:
Line 1 Lorem Ipsum
Line 2 Nonsense to throw away
Line 3 ~ This is the first tilde that appears in this file. Keep it and whatever comes after it til the end of the fileLine 1 Stuff to delete
Line 2 Other stuff to delete
Line 3 More stuff to delete
Line 4 Keep deleting
Line 5 ~ Keep everything on this line including the first character and everything in all subsequent linesThanks in advance.
-
Fairly easy, however you’ll need to use Notepad++ 7.9.1 or later (earlier versions will not handle the
\Aconstruct correctly) to do this:Use Replace in Files.
find:
\A(?s).*?~
repl:~Suggest making a backup of your whole fileset first; delete only after you’ve decided it works as intended.
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