From: Morris Keesan Date: 2009-06-21T12:18:50+09:00 Subject: Re: replacing repetition of characters in string This problem is a little under-specified, and it would be worth asking exactly what your friend is trying to accomplish. As a quick question, what should happen if the input contains THREE of the same character? Should "aaa" become aaa *aa*a *aaa* *a*a*a* or something else? On Sat, 20 Jun 2009 18:05:22 -0400, David Rio wrote: > Hi there, > > A friend of mine asked me to write a script that reads a file and > marks the double characters. > Something like: > > $ ruby scratch_ruby_drio.rb > INPUT > --------- > test. AA. I greatXXrr love it. > audi tt uu yes. > stop here, axmmen. > > OUTPUT > ------------ > {3} test. *AA*. I great*XX**rr* love it. > {2} audi *tt* *uu* yes. > {1} stop here, ax*mm*en. > > I coded something up that works but I don't like it: > > http://gist.github.com/133299 > > Do you guys have any other alternatives? > > -drd >