http://www.google.com
https://www.google.com
www.google.com
www.gowww.ogle.com
google.com
http://www.test.google.com
https://www.test.google.com
www.test.google.com
www.testgowww.ogle.com
test.google.com
toInsert = 'test.'
newStr = str.dup.sub!(/(?<=www\.)/, toInsert) || (toInsert + str)