How to remove text between two specified strings using Notepad++?
PRATAP CHAVA last edited by
I have following lines of data
File created by
Address 112: 044 0891.
Address 113: 044 1502.
Message log (200 messages)
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.
chcg last edited by chcg
Via regex search&replace:
(?s)^\t*File created by(.|\r\n)*?Message log
See 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.
guy038 last edited by
Hello, @pratap-chava and All,
Regarding your needs, I think that a suitable regex S/R could be :
(?s-i)^File created by.+?\RMessage log.+?$\R
Don’t forget to select the
Regular expresionsearch mode and to tick the
At beginning of the regex, the modifiers
(?s-i)mean that :
.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
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 (
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 (
And, due to the
emptyreplacement zone, all that block of text is, then, simply deleted !