Is there a way to use grep to find the first match instead of the last
match? For example, if I use

<!-- begin header -->
all kinds of HTML here
<!-- end header -->
<!-- begin header -->
all kinds of HTML here
 <!-- end header -->

And replace all, I get

<!-- begin header -->new HTML here<!-- end header -->

Instead of 

<!-- begin header -->new HTML here<!-- end header -->

<!-- begin header -->new HTML here<!-- end header -->

Is there a way to get the latter instead of the former?


On 6/8/06 12:25 AM, "Ronald J Kimball" <[EMAIL PROTECTED]> wrote:

> On Wed, Jun 07, 2006 at 06:56:11PM -0700, Michael Heth wrote:
> 
>> Is it possible to use grep to do the following?
>> 
>> find
>> 
>> <!-- begin header -->
>> 
>> all kinds of HTML here
>> 
>> <!-- end header -->
>> 
>> and replace with
>> 
>> <!-- begin header -->
>> 
>> new HTML here
>> 
>> <!-- end header -->
>> 
>> using the HTML comment tags as the delimiters.
>> 
>> And if the answer is yes, is there anyone who would be nice enough to
>> list the grep terms to get it to work?
> 
> Yes, that's a straightforward search and replace.
> 
> Find
> 
> <!-- begin header -->(?s:.*)<!-- end header -->
> 
> Replace
> 
> <!-- begin header -->
> 
> new HTML here
> 
> <!-- end header -->
> 
> 
> (?s) allows . to match newlines.
> 
> 
> Ronald



-- 
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <[EMAIL PROTECTED]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to:  <[EMAIL PROTECTED]>

Reply via email to