output = string.replace(fragment, "*", 1).replace("fragment", "").replace("*", fragment)
If needed, replace "*" with some token string which would never occur on your original string.
"Batteries included" doesn't mean that you can do everything you want with single built-in function call.