If the str to be replaced is always exactly "http://www.somelink.com" then:
str_replace() can replace it with a new url.
If it is not a consistent url then explode() the string to an array using a space as the delimiter, replace the array position containing the url with what you want and then implode the array back to the string with the glue a space character.