cooli0 has asked for the wisdom of the Perl Monks concerning the following question:

Hey, guys

I have a text like:

Blah blah http://somelink.com/ddd <a href="http://somelink.com/ddd" class="someclass" other_attributes>Check out http://somelink.com/ddd</a> blah blah http://somelink.com/ddd blahblah

Could someone point me on how to replace (and if its even possible) somelink.com, but, without replacing it inside href ?

Thanks

Replies are listed 'Best First'.
Re: Need help with regular expression
by choroba (Cardinal) on Apr 14, 2010 at 13:34 UTC
    Of course it is possible. This code uses the "zero-width negative look-behind assertion":
    s,(?<!href=")http://somelink.com/ddd,http://anotherlink.net/eee,g
      great! Thanks! I'm fool...I knew this technique..sorry) And thanks again
Re: Need help with regular expression
by Anonymous Monk on Apr 14, 2010 at 13:28 UTC