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.
-
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?
following 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.*?xyz
would match any of the following (and many more):abcdefxyz
abcdefghijxyz
- the entire english alphabet, in order
So perhaps
.*?
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: owner-phonogram-digest@phonogram.net (Phonogram Digest)
Date: Thu, 6 Jan 2011 02:41:43 -0500
To: phonogram-digest@phonogram.net
X-Account-Key: account2
X-UIDL: 1pAKuM2wD3Nl34c0
X-Mozilla-Status: 0001
X-Mozilla-Status2: 00000000
Status: U
Return-Path: owner-phonogram-digest@phonogram.net
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 ([69.20.22.243]) by mx-stork.atl.sa.earthlink.net (EarthLink SMTP Server) with ESMTP id 1pAKuM2rD3Nl34c0 for vinyl1@earthlink.net; 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
Message-ID: 201101060741.p067fhr30987@mail.phonogram.net
Reply-To: phonogram@phonogram.net
Sender: owner-phonogram-digest@phonogram.net
Errors-To: owner-phonogram-digest@phonogram.net
X-ELNK-AV: 0
X-ELNK-Info: sbv=0; sbrc=.0; sbf=0b; sbw=000;
Reply-to: phonogram@phonogram.net -
… 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: phonogram@phonogram.netThe text between those two lines are different in each block.
-
for this given example a regualr expression like
find what:(?s-i)Subject.*?Reply-to.*?\R
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 -
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.