... more rigorously correct ... optimization ...
For me, the issue is not rigor or optimization, but correctness. Insofar as I understand it, the OP requires an overall match on more-than-n contiguous identical characters (although an n-character match may be a component of the overall match). The regexes to which I object match equal-to-or-more-than-n such characters overall, and so are incorrect. The incorrectness of the matches is obscured, but not ameliorated, by the subsequent substitutions, which may replace a string S (which may be empty) with an identical string S.
The point can be exemplified by looking at what is matched by the qr{ (.)\1\1 \K \1* }xms regex (the most elegant, IMHO, in this thread) in a context that does not involve substitution. (Similar examples could be constructed for the other objectionable regexes.) All the empty strings are, in my view, unneeded (and improper) matches.
>perl -wMstrict -le "my $s = 'aaa...bbbb...ccccc...dddddd.x..yy'; print qq{'$2'} while $s =~ m{ (.)\1\1 \K (\1*) }xmsg; " '' '' 'b' '' 'cc' '' 'ddd'
Anyway, that's my story and I'm sticking to it.
In reply to Re^2: Supress similar chars in the string
by AnomalousMonk
in thread Supress similar chars in the string
by Lana
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |