Change your replacement pattern to:
<h2>&nbsp;&nbsp;&nbsp;\1</h2>

The \1 here means "the first parenthetical sub-pattern in the Find pattern."

I strongly suggest that you read Chapter 8 of the BBEdit manual, which
provides a very useful introduction to grep. The relevant section here is
'Writing Replacement Patterns,' pages 178-181.



On Tue, Sep 21, 2010 at 7:05 AM, OleBBSer <[email protected]>wrote:

> Hello Everyone,
>
> Patrick has already explained to me how to change text on the left and
> right sides of a phrase, without changing the center phrase, when the
> center phrase is a fixed string.
>
> However, what if the center phrase is NOT a fixed string, but rather a
> title of a book, for example, and in each of 1,000 documents, the
> title of the book is different?
>
> For example, suppose I have this string:
>
> <h3><font color="#000000">&nbsp;&nbsp;&nbsp;THIS IS A BOOK TITLE</
> font></h3>
>
> . . . and I want to use the multi-file search function to change it to
> this:
>
> <h2>&nbsp;&nbsp;&nbsp;THIS IS A BOOK TITLE</h2>
>
> I can find the original full string to change by using this:
>
> <h3><font color="#000000">&nbsp;&nbsp;&nbsp;(.+?)</font></h3>
>
> I tried to replace the beginning and end of the string -- without
> changing the book title in the middle -- by using this:
>
> <h2>&nbsp;&nbsp;&nbsp;(.+?)</h2>
>
> However, what I got was this:
>
> <h2><h3><font color="#000000">&nbsp;&nbsp;&nbsp;THIS IS A BOOK TITLE</
> font></h3>nbsp;<h3><font color="#000000">&nbsp;&nbsp;&nbsp;THIS IS A
> BOOK TITLE</font></h3>nbsp;<h3><font
> color="#000000">&nbsp;&nbsp;&nbsp;THIS IS A BOOK TITLE</font></h3>nbsp;
> (.+?)</h2>
>
> So apparently, I am doing something wrong.
>
> And as I said, what complicates this is the fact that the book title
> is different in each of the 1,000 documents.
>
> Thanks in advance to anyone who can assist. I'm sure this is an easy
> one for you long-time greppers.  ;)
>
> --
> You received this message because you are subscribed to the
> "BBEdit Talk" discussion group on Google Groups.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<bbedit%[email protected]>
> For more options, visit this group at
> <http://groups.google.com/group/bbedit?hl=en>
> If you have a feature request or would like to report a problem,
> please email "[email protected]" rather than posting to the group.
> Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>
>

-- 
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
If you have a feature request or would like to report a problem, 
please email "[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>

Reply via email to