|
|
| Don't ask to ask, just ask | |
| PerlMonks |
Re: Yet Another Rosetta Code Problem (Perl, Ruby, Python, Haskell, ...)by Kjetil_Skotheim (Initiate) |
| on Oct 03, 2008 at 20:34 UTC ( #715274=note: print w/ replies, xml ) | Need Help?? |
|
Shorter Perl 5 variants: Destroys $s: $s="ZBBBCZZ"; $s=~s/((.)\2*)/push@x,$1/eg; Nondestructive: $s="ZBBBCZZ"; $s=~s/((.)\2*)/push@x,$1;$1/eg; Needs a counter $i: $s="ZBBBCZZ"; @x=grep++$i%2,$s=~/((.)\2*)/g;
In Section
Meditations
|
|
||||||||||||||||||||