in reply to Split a string into items of constant length
One way...
And if your strings are longer and you want to chop it all up the same way...my $string = "a(b)cd(e)f"; my @parts = split /(?=.{5}$)/, $string';
It would be simpler to drop split in this case though...my $string = "a(b)cd(e)fg(h)ij(k)l"; my @parts = split /(?=(?:.{5})+$)/, $string';
my $string = "a(b)cd(e)fg(h)ij(k)l"; my @parts = $string =~ /(.{5})/g;
-sauoq "My two cents aren't worth a dime.";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Split a string into items of constant length
by blazar (Canon) on Oct 04, 2005 at 10:29 UTC | |
by truedfx (Monk) on Oct 04, 2005 at 13:40 UTC | |
by sauoq (Abbot) on Oct 04, 2005 at 10:47 UTC |