http://www.perlmonks.org?node_id=512848


in reply to Re: Elegant way to split into sequences of identical chars?
in thread Elegant way to split into sequences of identical chars?

With aminor change to qr/(.)\1*/; to pick non repeated characters, it works fine.

Very elegant++.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^3: Elegant way to split into sequences of identical chars?
by pKai (Priest) on Nov 30, 2005 at 10:07 UTC
    ingenious!

    And not only

    elegant++
    but also by far the fastest solution so far, provided Benchmark not lying to me.

    Since it is also very compact already, we get the most compact variant so far with

    /((??{'(.)\1*'}))/g

    This is not as fast as the precompiled regex, of course, but still faster than the other snippets seen.