in reply to When greedy constructs do battle, can I choose the winner?
use strict; use warnings; my @nos = qw{ 12304500 123 1234567000000 987045027000 }; print map { sprintf qq{%15s : %5s\n}, @$_ } map { [ $_, m{(\d{1,5})(?=0*\z)} ] } @nos;
Here's the output.
12304500 : 23045 123 : 123 1234567000000 : 34567 987045027000 : 45027
I hope this is of use.
Cheers,
JohnGG
Update: No, that doesn't work unless you make the \d{1,5} non-greedy, as suggested by duff
|
|---|