How to start 2. How do I delete blocks of text?
Now to my second question: How do I delete blocks of text?
The text immediately before the block is unique, and also the text immediately after the block. The blocks themselves are from 2 to maybe 50 lines long and starts and ends with the same group of words.
I assume a regex could do the job but for this to make it work there is a need to know your data exactly.
Alan Kilborn last edited by
So Notepad++ can do a few types of searches, one is a “normal” search where it searches for exactly what you type; a second type of search is called a “regular expression” search. In this 2nd type of search, certain characters that you type have special meaning, for example a
.means to match any character, a
*means to match the previous thing zero or more times, a
*means to match the previous as few times as possible. Putting it all together,
.*?could possibly come between your leading text and your following text.
So as an example,
abc.*?xyzwould match any of the following (and many more):
- the entire english alphabet, in order
.*?will appear in the middle of what you need, but @Ekopalypse is correct, we need more infos.
****This is the longest block: ****
Subject: Phonogram Digest V15 #1
From: firstname.lastname@example.org (Phonogram Digest)
Date: Thu, 6 Jan 2011 02:41:43 -0500
Received: from noehlo.host ([127.0.0.1]) by mx-stork.atl.sa.earthlink.net (EarthLink SMTP Server) with SMTP id 1pAKuG2wD3Nl34c0; Thu, 6 Jan 2011 02:42:52 -0500 (EST)
Received: from mail.phonogram.net ([188.8.131.52]) by mx-stork.atl.sa.earthlink.net (EarthLink SMTP Server) with ESMTP id 1pAKuM2rD3Nl34c0 for email@example.com; Thu, 6 Jan 2011 02:42:52 -0500 (EST)
Received: (from majordom@localhost) by mail.phonogram.net (8.11.6/8.11.6) id p067fhr30987 for phonogram-digest-outgoing; Thu, 6 Jan 2011 02:41:43 -0500
X-ELNK-Info: sbv=0; sbrc=.0; sbf=0b; sbw=000;
… and what do you want to delete?
Everything from (and including) the first part of the first line Subject: Phonogram Digest
to (and including) the last line Reply-to: firstname.lastname@example.org
The text between those two lines are different in each block.
for this given example a regualr expression like
replace with is empty
would do it BUT this assumes that each block starts with Subject and ends with Reply-to and
there is no Reply-to in between.
Note, this search is case sensitive, meaning Reply-To and Reply-to is different.
Thank you. That worked with a little editing of the expression to
(?s-i)Subject: Phonogram Digest.?Reply-to: .?\R
Alan Kilborn last edited by
Another gotcha when posting here is that when you use
*it gets turned into an italics font. See that? So the regular expression you posted makes no sense. It should be, AFAICT,
(?s-i)Subject: Phonogram Digest.*?Reply-to: .*?\R
You can get the special text I just showed by wrapping it in backticks, also known as grave accents.