in reply to how to replace a matched pattern in a string with a different pattern of same length?

Quick and dirty:
perl -le '$_="00110011111110111111111111111110"; $m=( sort({length($b) +<=>length($a)} /(1+)/g ) )[0];s/$m/2 x length $m/e;print'

Paul

  • Comment on Re: how to replace a matched pattern in a string with a different pattern of same length?
  • Download Code