From: Barry Margolin <barmar@genuity.net>
Subject: Re: Newbie regexp question
Date: Wed, 30 Oct 2002 16:49:40 GMT [thread overview]
Message-ID: <E4Uv9.15$mJ3.1131@paloalto-snr1.gtei.net> (raw)
In-Reply-To: 8765vkkkko.fsf@fbigm.here
In article <8765vkkkko.fsf@fbigm.here>,
Friedrich Dominicus <frido@q-software-solutions.com> wrote:
>Paul Cohen <paco@enea.se> writes:
>
>> Hi
>>
>> I want to do a Emacs regexp search and replace on a HTML file containing
>> patterns like this:
>>
>> <!--Test-->
>> ...
>> <!--End of Test-->
>>
>> Where "..." denotes a variable number of lines of HTML text.
>>
>> I want to search for all occurrences of the above pattern and then
>> remove them from the HTML file!
>>
>> I've tried a number of variants without any success. For example the
>> following regexp doesn't work:
>>
>> <!--Test-->\(.*\n\)*<!--End of Test-->
>I would restate the problem. It does not make much sense to me to
>match over a bunch of lines you do not want to handle.
>
>So how about
>M-C-% ^[ \t]*<!--.*Test.*--> with: RET
This removed the <!--Test--> and <!--End of Test--> lines, but it doesn't
remove all the lines in between, which I think is his real goal.
The problem with the OP's attempted solution is that * is greedy. So it
will match everything from the first <!--Test--> to the last <!--End of
Test-->, including all the non-test stuff in between.
I would do this using a keyboard macro that searches for <!--Test-->, sets
a mark, searches for <!--End of Test-->, and then kills the region.
--
Barry Margolin, barmar@genuity.net
Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
next prev parent reply other threads:[~2002-10-30 16:49 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-30 15:07 Newbie regexp question Paul Cohen
2002-10-30 15:33 ` Friedrich Dominicus
2002-10-30 16:46 ` Paul Cohen
2002-10-30 17:19 ` Friedrich Dominicus
2002-10-30 17:24 ` Michael Slass
2002-10-30 17:42 ` Friedrich Dominicus
2002-10-30 17:50 ` Michael Slass
2002-10-30 21:37 ` Michael Slass
2002-10-30 16:49 ` Barry Margolin [this message]
2002-10-30 18:48 ` Stefan Monnier <foo@acm.com>
2002-10-30 19:29 ` Barry Margolin
2002-10-31 14:45 ` kgold
-- strict thread matches above, loose matches on Subject: below --
2002-10-30 16:57 Bingham, Jay
2002-10-30 21:12 Bingham, Jay
[not found] <mailman.1036012442.21874.help-gnu-emacs@gnu.org>
2002-10-31 13:56 ` Paul Cohen
2002-10-31 14:41 ` Friedrich Dominicus
2002-10-31 18:11 Bingham, Jay
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='E4Uv9.15$mJ3.1131@paloalto-snr1.gtei.net' \
--to=barmar@genuity.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).