in reply to Elegant way to split into sequences of identical chars?
This is a little crufty, I'll admit, but I like it!
This splits a string at all locations that 1) are not the beginning of the string, and 2) are not followed by the character immediately preceding this location.sub splitter { local $_ = shift; split /(?<!^)(?!(??{ quotemeta substr($_, $-[0]-1, 1) }))/; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Elegant way to split into sequences of identical chars?
by tphyahoo (Vicar) on Dec 05, 2005 at 09:50 UTC |
In Section
Seekers of Perl Wisdom