in reply to Find and replace with regex

You could use a negative look-ahead assertion (see perlre) $sample =~ s{(img src=")(?!http)}{$1$http}g; which gives the following output:
<img src="http://domain.com/pics/local.jpg" alt="" /> <img src="http://remote.com/pics/remote.jpg" /> more confusion, just in case: 3:00pm 12/12/12 other urls <a href="http://fake.com"> http://fake.com</a>

But it's probably fraught with danger.

Replies are listed 'Best First'.
Re^2: Find and replace with regex
by JayBee (Scribe) on Jan 09, 2008 at 12:05 UTC
    Looks good to me. What dangers do you see, besides having a folder or file named "httplaces" for example?
    I think this solution works best. :)
      It's just too fragile. Consider
      <img src="..." />

      as just one simple example that breaks the previous regexp.