rotate a vector with a regex?by misterperl (Beadle)
|on Nov 20, 2012 at 21:46 UTC||Need Help??|
misterperl has asked for the
wisdom of the Perl Monks concerning the following question:
Say I'd like to move the first char in a string to the other end. An obvious choice might be
But I wondered- what if I tried to move it pairwise along the string (bubble it). It seems like as long as I could get the matching position to move by 1, instead of 2, I could do it that way. Just for academic reasons I wondered..
It seems like something along these lines, with the positive lookhead, could potentially bubble the char:
which I'd hoped would perform these steps: 12345
but instead it produced 5 warnings and left the string unchanged (I presume the warnings were that $2 was undef)..
Thoughts, wondrous monks?