my $http='http://domain.com/'; my $sample=' more confusion, just in case: 3:00pm 12/12/12 other urls http://fake.com'; #-- THIS ------------------- $sample=~s{(img src=")(\w?)[^:]}{$1$http$2}g; # something from my book, POSIX ? not very clear #-- OR --------------------- $sample=~s/(img src=")(\w.+?)(:?)/"$1$http$2"if(!$3)/eg; #-- END --------------------