in reply to Problem With Split
#!/usr/local/bin/perl -w use strict; my $number = '00120034'; # split at the position that has 4 digits # behind and 4 digits ahead my ($n1, $n2) = split /(?<=\d{4})(?=\d{4})/, $number; print "$n1, $n2\n"; # strip leading 0's ($n1, $n2) = map { int $_ } ($n1, $n2); print "$n1, $n2\n";
0012, 0034 12, 34
{ local $_ = $amount; /\./ ? s/(?<=\d)(?=(\d{3})+(?:\.))/,/g : s/(?<=\d)(?=(\d{3})+(?!\d)) +/,/g; $amount = $_; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Problem With Split
by Roy Johnson (Monsignor) on Jun 16, 2004 at 18:59 UTC | |
|
Re^2: Problem With Split
by revdiablo (Prior) on Jun 16, 2004 at 18:34 UTC |