Is this a case where adding the /o modifier to the s/// operator might be helpful? It's an efficiency measure intended to ensure (or help ensure, I think) the regex is only compiled once.
s/((.)\2{$n})\2*/$1/go;
In reply to Re^3: Supress similar chars in the string
by Jim
in thread Supress similar chars in the string
by Lana
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |