Replacing all occurrences of characters in a string with one new character?
843785Oct 24 2008 — edited Oct 24 2008Hi there,
I'm looking for a way that I could replace all occurrences of a set of specific characters with just one new character for each occurrence.
For example if I have a string which is "word1...word2.......word3....word4............word5" how would I be able to replace this with just one character such as ":" for each set of "." so that it would essentially appear like this "word1:word2:word3:word4:word5"
If I just use replace(".", ":") I am left with "word1:::word2:::::::word4::::word5::::::::::::"
So therefore I'm guessing this would require the use of replaceAll() maybe? but I'm not really very familiar with how regular expressions work and how this would be accomplished using them.
Any help would be greatly appreciated :) Thanks.