I have a website which allows users to comment on photos. Of course, users leave comments like:
\'OMGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
Regex would be overkill. Try this:
public static string RemoveRepeatedChars(String input, int maxRepeat) { if(input.Length==0)return input; StringBuilder b = new StringBuilder; Char[] chars = input.ToCharArray(); Char lastChar = chars[0]; int repeat = 0; for(int i=1;i