Without using the regex, you may traverse through each character one by one, remember the previous character pattern and the pattern count.
You may, but why would you write such a custom, special-case state machine in Perl? This is precisely what regular expressions in scripting languages like Perl are for.
$ echo '........ aaaaaaaasssssss __________ ++++++++++ ---------' | > perl -pe 's{(.)\1\1\K\1+}{}g' ... aaasss ___ +++ --- $
That's unbeatably simple and elegant, don't you think?
In reply to Re^2: Supress similar chars in the string
by Jim
in thread Supress similar chars in the string
by Lana
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |