in reply to Simple regex question
Scan string.....
use Data::Dumper; my $str = "aaabbccccdd eee"; my $last = ''; my @res; my $i = -1; for my $chr ( split //, $str ) { $i++ unless $chr eq $last; $res[$i] .= $chr; $last = $chr; } print Dumper \@res; __DATA__ $VAR1 = [ 'aaa', 'bb', 'cccc', 'dd', ' ', 'eee' ];
OK so it looks like C without the pointers. So shoot me!
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Simple regex question
by Anonymous Monk on Oct 23, 2003 at 13:35 UTC | |
by tachyon (Chancellor) on Oct 23, 2003 at 13:44 UTC | |
by Anonymous Monk on Oct 23, 2003 at 20:30 UTC | |
by tachyon (Chancellor) on Oct 23, 2003 at 13:41 UTC |