Use Split() to split the string into an array using ~ as the delimiter. Then join it manually into a string using a for loop, but on the second iteration instead of joining with ~ join them with -

Just of the top of my head. There's probably a hundred more ways of going about it.