$text =~ s/(.)(?=\1\1\1)//gs; [download]
In reply to More efficient way to truncate long strings of the same character by kurtis