help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Newbie regexp question


From: Barry Margolin
Subject: Re: Newbie regexp question
Date: Wed, 30 Oct 2002 16:49:40 GMT

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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]