in reply to Combinatorics in Perl
Here's one regex (plus while loop) for it:
while ( s{ ^ (.*?) (\s* \S+)_DEL (.*) $ } {$1$3\n$1$2$3}xmg ) {}
I am trying to cook up one using (?{ ... }) constructs, but not having as much luck.
Update: Oops, left off the empty loop body...
Update (at 2004-04-29 23:49 -0700): Here is a more procedural solution that uses the same basic idea as above. It might be a bit more useful, as it returns a list of variants instead of one big string. (Would be interesting to benchmark them...)
sub del_selective { my $n = shift; if ( $n =~ m/(.*?)(\s*\S+)_DEL(.*)/s ) { my $s1 = $1.$3; my $s2 = $1.$2.$3; return ( del_selective( $s1 ), del_selective( $s2 ) ); } else { return ( $n ); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Combinatorics in Perl
by wouldbewarrior (Acolyte) on Apr 30, 2004 at 06:40 UTC | |
|
Re: Re: Combinatorics in Perl
by pizza_milkshake (Monk) on Apr 30, 2004 at 07:10 UTC |