in reply to Re: Re: Increase number per regex replacement
in thread Increase number per regex replacement

True true, but this was meant to be a whimscial/goldbergian solution. You'd have to be wary of the same issue with /e though not /ge ;-) Of course this fixes that:
$i = 0; @no = qw(one two three four five); foreach ( @no ){ my $str = ''; while( s/([^e]*)e// ){ $str .= $1 . "fee" . $i++; } $_ = $str . $_; #UPDATED: Append addresses Re: to this node } print "@no\n";

--
perl -pe "s/\b;([st])/'\1/mg"

Replies are listed 'Best First'.
Re: Re: Re: Re: Increase number per regex replacement
by blakem (Monsignor) on Jan 08, 2002 at 11:34 UTC
    Hmmm... I don't mean to keep poking at a not-too-serious answer, but I don't think that works exactly right either. What happens with numbers like 'seven' or 'ten' that have an 'e' in the middle, but not at the end? The last non-matching-non-'e' part gets removed.

    Update: for that matter, the numbers w/o an 'e' in them at all are being nulled out...
    Update2: Updated code now seems to work properly, $str is built up while $_ is torn down...

    -Blake