Change Url inside a string and mantain path

I want to change the Url and mantain the data path.

I want to change the url from

www.abc.com/emailreply/1274_743273.wav

to

media1.abc.com/emailreply/1274_743273.wav

but only if the /emilreply/*.wav are their