Remove duplicate words from string | SoloLearn: Learn to code for FREE!


Remove duplicate words from string

I shall remove duplicate words in the string given with a few conditions (from original task): "leaving only single (first) words entries. By word we shall mean the unit that consists only of latin alphabet characters. Only following punctuation marks (. , ! ? - : ; ) and space characters can be delimiters between words". The solution would be presented without using LINQ. Ive implemented two algorithms wasnt work right: 1) based clearly on char iteration and string.Replace(); 2) Replace() + regex. I just have idea 😞

7/4/2019 5:39:46 PM


5 Answers

New Answer


Well, it became much easier to solve just ive posted this 🧐. The solution is the following code:


sneeze you remarks are welcome ☺️


Well done. This totally meets the requirements. One thing that can be improved. At the moment some how the word "big" is replaces with " " (3 spaces) Have not been able to address where this goes wrong. Because you do replace big with "" (no spaces) in the function Simply remove every second space Or have a look why the 3 spaces are there


sneeze ok, thanks ☺️


Please share the code you already have made. Please use the playground. What do you mean with "wasnt work right" It was not accepted by the teacher or the result did not meet the requirements ?