Adding keywords at specific places in a string using javascript

I am writing a code to create a new string from a predefined string by adding some keywords at particular places in the original string i was trying the indexOf() feature to achieve this but unable to complete the work

for eg. if my string is

now i want to add some keywords to this string at specific places to make the final string as

here i have replaced ‘www’ by ‘goo’ and alos added ‘goo’ between the ‘.in/webhp’ as ‘.in/goo/webhp’

Use a regular expression to specify the various patterns in the content and what they are to be replaced with.

What i have tried is like

var flip;
   var res=

    if(subdomain.indexOf("?") == -1){
         var res =''+subdomain + '?yahoo';
        if(subdomain.indexOf("&") == -1)
         var res =''+ subdomain + '&yahoo';
            subdomain=subdomain.substring( 0, subdomain.indexOf( "&" ) );
            var res = ''+ subdomain + '&yahoo';

but this is not working to generate the final string any suggetions

To do that conversion (replacing www wit goo and adding /goo) to any address containing you can do the following

flip = '';
re = /^(.*?\/\/).*?(\.google\.co\.in)(\/.*)$/;
flip = flip.replace(re, '$1goo$2/goo$3');