It can also be done with regular expressions and the replaceAll() method of String class, if you're somewhat familliar with regular expressions. Although I have to admit, this regex doesnt preserve punctuation that occurs after a repeated word i.e.: "back, back, back," --> "back"
I suspect that if you play around with it a little, that can be fixed too.
[edit: found a bug in my regex] [ March 25, 2006: Message edited by: Garrett Rowe ]
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop