[X-Unix] Grep and backreferences with BBEdit

Rod Buchanan lists at sofstats.com
Tue Oct 12 16:02:49 PDT 2004


On 10/12/04 1:12 PM, "Nick Scalise" <nickscalise at mac.com> wrote:

> So, I think I have the first part figured out, I find <a
> href="[a-zA-Z0-9+]+.jpg"> using grep in BBEdit's find dialog, this seems to
> produce the desired result. Please let me know if there is a better way.
> 
> Where I am lost is the backreference part. What is the pattern I would add in
> the replace dialog that would add 'images/'  so that the original <a
> href='name.jpg'> would end up <a href="images/name.jpg">

Search:
    <a href="(.+?)"(.*?)>

Replace:
    <a href="images/\1"\2>

Changes:
    <a href="name.jpg">
    <h1>blah</h1>
    <a href="name2.jpg" target="_new">name2.jpg</a>
    <a href="blue.jpg">

to:
    <a href="images/name.jpg">
    <h1>blah</h1>
    <a href="images/name2.jpg" target="_new">name2.jpg</a>
    <a href="images/blue.jpg">

-- 
Rod

"Politics and Poker, Politics and Poker,
Shuffle up the cards And find the joker.
    -- Sheldon Harnick and Jerry Bock, from "Fiorello"




More information about the X-Unix mailing list