in reply to Simple regex question
echo 'aaabbccccdd eee' | perl -aF'(.)(?!\1)' -lne 'while(@F){push@M,sh +ift(@F).shift(@F)}print for @M'
Producing:
aaa bb cccc dd eee
Update:
Shorter :
echo 'aaabbccccdd eee'|perl -aF'(.)(?!\1)' -lne 'for(@F){$M[$c].=$_;$c+=$d++%2}print for @M'
Not using split, and shorter still:
echo 'aaabbccccdd eee'|perl -lne 'while($_){s/((.)\2*)//;push@F,$1}print for @F'
|
|---|