Find / Replace with TOOLBUCKET
-
Hello NPP-experts,
i would like to add a new line to a big file after a finding section. How can i do this? I have installed the plugin TOOLBUCKET - Multiline Find Replace. Not in every section i need this new line. To example i create a samplefile with car company’s. My idea was with reg exp.
FIND: (^automarke_._deutschlandDiesel)
REPLACE: \1\n NEW LINE
-> does not workmyfile with more than 120000 lines:
automarke_opel_deutschland
Ascona
Kadett
Corsa
Diesel not in every section
###Here add a new line###automarke_audi_deutschland
A3
A5
A6
Benzin
###NO new line###automarke_opel_deutschland
Ascona
Kadett
Corsa
Diesel not in every section
###Here add a new line###Thanks a lot
-
So you might start with this text (maybe better than your exact example, which embeds meta stuff in it):
automarke_opel_deutschland Ascona Kadett Corsa Diesel automarke_audi_deutschland A3 A5 A6 Benzin automarke_opel_deutschland Ascona Kadett Corsa DieselAnd you want to turn it into this:
automarke_opel_deutschland Ascona Kadett Corsa Diesel foobar automarke_audi_deutschland A3 A5 A6 Benzin automarke_opel_deutschland Ascona Kadett Corsa Diesel foobarI don’t think TOOLBUCKET provides you anything over-and-above what standard regular-expression replace gives you for this…
So really quickly (I’m sure there are better ways) you can do it with this:
Find what zone:
(?-s)automarke_.+?_deutschland(?s).+?^(?:(Diesel).+?^$|$)
Replace with zone:$0(?1foobar\r\n)Note: Assumes Windows line-endings (
\r\n). -
Thanks a lot.
It works with a little change(REPLACE: $0(HELLO WORLD\r\n) ) in my file.
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