On Saturday 01 December 2007 18:16, Eric Krause wrote:
>
> Hello all,

Hello,

> I have a string like:
> 11111xxx11xxxx111111xx11x1xxxx
>
> I would like to replace the 1's with the total of 1's like this:
> 5xxx2xxxx6xx2x1xxxx


$ perl -le'
$_ = q[11111xxx11xxxx111111xx11x1xxxx];
print;
s/(1+)/@{[($l=$1)=~y|1|1|]}/g;
print;
'
11111xxx11xxxx111111xx11x1xxxx
5xxx2xxxx6xx2x1xxxx



:-)

John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to