Posts

Showing posts from December, 2011

Remove duplicate strings - C#

Here is the code 1 2 3 var words = new HashSet(); string text = "praveen kumar thalluri praveen kumar thalluri" ; text = Regex.Replace(text, "\\w+" , m => words.Add(m.Value.ToUpperInvariant())? m.Value: String.Empty); Courtesy: http://stackoverflow.com/questions/1058783/regular-expression-to-find-and-remove-duplicate-words