Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: Elegant way to split into sequences of identical chars?

by BrowserUk (Pope)
on Nov 30, 2005 at 04:45 UTC ( #512848=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://512848]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2019-05-25 05:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you enjoy 3D movies?



    Results (151 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!