How to remove text between two specified strings using Notepad++?
-
I have following lines of data
File created by
Status 23:
Status 24:
Status 25:
Status 26:
Status 27:
Status 28:
Status 29:
Status 30:
Status 31:
Address
Address 112: 044 0891.
Address 113: 044 1502.
Message log (200 messages)Message 1:
Message 2:
Message 2:
Message 2:
Message 2:
Message 2:I wish to delete text between line 1(File created by ) and upto line “Message log (200 messages)”.
Can someone please provide some suggestions and thoughts on this?
Thank you very much.
-
Via regex search&replace:
Search term:
(?s)^\t*File created by(.|\r\n)*?Message logReplace.with:
Message logSee also https://notepad-plus-plus.org/community/topic/15765/faq-desk-where-to-find-regex-documentation
and most probably there are more elegant searches possible. -
Hello, @pratap-chava and All,
Regarding your needs, I think that a suitable regex S/R could be :
SEARCH :
(?s-i)^File created by.+?\RMessage log.+?$\RREPLACE
Leave EmptyDon’t forget to select the
Regular expresionsearch mode and to tick theWrap-aroundoptionNotes :
-
At beginning of the regex, the modifiers
(?s-i)mean that :-
The
.dot regex character will match any single character ( Standard and EOL chars ) -
The search is performed in a sensitive way. If you prefer insensitive matches just change that part with
(?si)!
-
-
Then the part
File created by.+?\RMessage loglooks, from beginning (^) of line, for any text, beginning with File created by and ending at the first expression Message log, preceded by a line-break (\R) -
Now, the final part
.*?$\Rtries to match a range of any character, ending at the nearest end of line ($), and followed with a line-break (\R)
And, due to the
emptyreplacement zone, all that block of text is, then, simply deleted !Cheers,
guy038
-
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