in reply to Creating a fill-in regexp

Use a 'substitute' ;-)
$s1 = '0000010000000100000100001'; $s1 =~ s/1(0+)1/'1'x((length($1)+2))/eg;
Output
 0000011111111100000111111

Replies are listed 'Best First'.
Re: Re: Creating a fill-in regexp
by jpfarmer (Pilgrim) on Sep 24, 2003 at 19:15 UTC
    It never occured to me that I could replace with a variable-length string. Oops. I feel pretty dumb now.

    Thanks for your help!