This one would be faster
$text =~ s/(.)\1{3,}/$1$1$1/gs;
Updated: It is faster because it makes one substitution per char sequence. It replaces four or more repeated characters by three at one time.
In reply to Re: More efficient way to truncate long strings of the same character
by ccn
in thread More efficient way to truncate long strings of the same character
by kurtis
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |