while ($body_str =~ /"http:\/\/([^ \/"]+)[^ "]*"/g) { if ($1 ne 'www.danheller.com') { $pos = pos($body_str); substr($body_str, $pos - 1, 1) = '" target="blank"'; pos($body_str) = $pos; } }