Wednesday, 18 September 2013

Java Edit Text with certain rules

Java Edit Text with certain rules

I have to edit text with certain rules :
The repetitive letters in the same word will be reduced to single letter.
("Questions" instead of "QuestionssSsS")
More than one gaps between words will be reduced to a single space("go to
the cinema" instead of "go to the cinema")
Single letter which separated from the word will be connect to the
word("first ten person" instead of "firs t ten person" )
For example :
String s = "I am enouuugGh of an artis t to draw freely upon my
imagination. ImaginatioOO n is more importan t than knowledge.
KKkKkKnowledge is limited. Imagination encircles the wwWorl d.";
Expected output :
I am enough of an artist to draw freely upon my imagination. Imagination
is more important than knowledge. Knowledge is limited. Imagination
encircles the world.
Please give suggestions and advice..

No comments:

Post a Comment