Ambiguous request. The reply I posted assumed you want to delete lines with three adjacent occurrences of a character. The reply elixir_sinari posted assumed you want to delete any line with three occurrences of a character whether or not they are adjacent. The input you gave will give the same results for either interpretation. What was it that you wanted?
That approach isn't very robust. The first argument to gsub is an extended regular expression. If the line contains a . , it will match every character. If there's a ? , + , * , or some other metacharacter, there may be a runtime regular expression compilation failure.
What you're attempting can be done easily with grep and a single regular expression: